diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs index 074e3ec43..023dde674 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs @@ -9,7 +9,9 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet public class BroadcastheNet : TorrentIndexerBase { public override string Name => "BroadcasTheNet"; - + public override string[] IndexerUrls => new[] { "https://api.broadcasthe.net/" }; + public override string[] LegacyUrls => new[] { "http://api.broadcasthe.net/" }; + public override string Description => "BroadcasTheNet (BTN) is an invite-only torrent tracker focused on TV shows"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override bool SupportsRss => true; public override bool SupportsSearch => true; @@ -18,11 +20,6 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet public override IndexerCapabilities Capabilities => SetCapabilities(); public override TimeSpan RateLimit => TimeSpan.FromSeconds(5); - public override string[] IndexerUrls => new string[] { "https://api.broadcasthe.net/" }; - public override string[] LegacyUrls => new string[] { "http://api.broadcasthe.net/" }; - - public override string Description => "BroadcasTheNet (BTN) is an invite-only torrent tracker focused on TV shows"; - public BroadcastheNet(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { @@ -30,7 +27,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet public override IIndexerRequestGenerator GetRequestGenerator() { - var requestGenerator = new BroadcastheNetRequestGenerator() { Settings = Settings, PageSize = PageSize, Capabilities = Capabilities }; + var requestGenerator = new BroadcastheNetRequestGenerator { Settings = Settings, PageSize = PageSize, Capabilities = Capabilities }; var releaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id); if (releaseInfo != null) diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs index 4650671c5..88d66a0b2 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet public IList ParseResponse(IndexerResponse indexerResponse) { - var results = new List(); + var releaseInfos = new List(); var indexerHttpResponse = indexerResponse.HttpResponse; switch (indexerHttpResponse.StatusCode) @@ -69,60 +69,71 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet if (jsonResponse.Result.Results == 0 || jsonResponse.Result?.Torrents?.Values == null) { - return results; + return releaseInfos; } var protocol = indexerResponse.HttpRequest.Url.Scheme + ":"; foreach (var torrent in jsonResponse.Result.Torrents.Values) { - var torrentInfo = new TorrentInfo(); + var flags = new HashSet(); - torrentInfo.Guid = string.Format("BTN-{0}", torrent.TorrentID); - torrentInfo.Title = CleanReleaseName(torrent.ReleaseName); - torrentInfo.Size = torrent.Size; - torrentInfo.DownloadUrl = RegexProtocol.Replace(torrent.DownloadURL, protocol); - torrentInfo.InfoUrl = string.Format("{0}//broadcasthe.net/torrents.php?id={1}&torrentid={2}", protocol, torrent.GroupID, torrent.TorrentID); - - //torrentInfo.CommentUrl = - if (torrent.TvdbID.HasValue) + if (torrent.Origin.ToUpperInvariant() == "INTERNAL") { - torrentInfo.TvdbId = torrent.TvdbID.Value; + flags.Add(IndexerFlag.Internal); } - if (torrent.TvrageID.HasValue) + var releaseInfo = new TorrentInfo + { + Guid = $"BTN-{torrent.TorrentID}", + InfoUrl = $"{protocol}//broadcasthe.net/torrents.php?id={torrent.GroupID}&torrentid={torrent.TorrentID}", + DownloadUrl = RegexProtocol.Replace(torrent.DownloadURL, protocol), + Title = CleanReleaseName(torrent.ReleaseName), + Categories = _categories.MapTrackerCatToNewznab(torrent.Resolution), + InfoHash = torrent.InfoHash, + Size = torrent.Size, + Grabs = torrent.Snatched, + Seeders = torrent.Seeders, + Peers = torrent.Leechers + torrent.Seeders, + PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime().AddSeconds(torrent.Time), + Origin = torrent.Origin, + Source = torrent.Source, + Container = torrent.Container, + Codec = torrent.Codec, + Resolution = torrent.Resolution, + Scene = torrent.Origin.ToUpperInvariant() == "SCENE", + IndexerFlags = flags, + DownloadVolumeFactor = 0, + UploadVolumeFactor = 1, + MinimumRatio = 1, + MinimumSeedTime = torrent.Category.ToUpperInvariant() == "SEASON" ? 432000 : 86400, // 120 hours for seasons and 24 hours for episodes + }; + + if (torrent.TvdbID is > 0) { - torrentInfo.TvRageId = torrent.TvrageID.Value; + releaseInfo.TvdbId = torrent.TvdbID.Value; } - torrentInfo.PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime().AddSeconds(torrent.Time); - - //torrentInfo.MagnetUrl = - torrentInfo.InfoHash = torrent.InfoHash; - torrentInfo.Seeders = torrent.Seeders; - torrentInfo.Peers = torrent.Leechers + torrent.Seeders; - - torrentInfo.Origin = torrent.Origin; - torrentInfo.Source = torrent.Source; - torrentInfo.Container = torrent.Container; - torrentInfo.Codec = torrent.Codec; - torrentInfo.Resolution = torrent.Resolution; - torrentInfo.UploadVolumeFactor = 1; - torrentInfo.DownloadVolumeFactor = 0; - torrentInfo.MinimumRatio = 1; + if (torrent.TvrageID is > 0) + { + releaseInfo.TvRageId = torrent.TvrageID.Value; + } - torrentInfo.Categories = _categories.MapTrackerCatToNewznab(torrent.Resolution); + if (torrent.ImdbID.IsNotNullOrWhiteSpace() && int.TryParse(torrent.ImdbID, out var imdbId)) + { + releaseInfo.ImdbId = imdbId; + } // Default to TV if category could not be mapped - if (torrentInfo.Categories == null || !torrentInfo.Categories.Any()) + if (releaseInfo.Categories == null || !releaseInfo.Categories.Any()) { - torrentInfo.Categories = new List { NewznabStandardCategory.TV }; + releaseInfo.Categories = new List { NewznabStandardCategory.TV }; } - results.Add(torrentInfo); + releaseInfos.Add(releaseInfo); } - return results; + return releaseInfos; } private string CleanReleaseName(string releaseName)