Fixed: (BTN) Add MST, indexer flags and parse IMDb ID

pull/1943/head
Bogdan 1 year ago
parent 6d134750ff
commit fdaca64d60

@ -9,7 +9,9 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
public class BroadcastheNet : TorrentIndexerBase<BroadcastheNetSettings> public class BroadcastheNet : TorrentIndexerBase<BroadcastheNetSettings>
{ {
public override string Name => "BroadcasTheNet"; 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 IndexerPrivacy Privacy => IndexerPrivacy.Private;
public override bool SupportsRss => true; public override bool SupportsRss => true;
public override bool SupportsSearch => true; public override bool SupportsSearch => true;
@ -18,11 +20,6 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
public override IndexerCapabilities Capabilities => SetCapabilities(); public override IndexerCapabilities Capabilities => SetCapabilities();
public override TimeSpan RateLimit => TimeSpan.FromSeconds(5); 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) public BroadcastheNet(IIndexerHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger)
: base(httpClient, eventAggregator, indexerStatusService, configService, logger) : base(httpClient, eventAggregator, indexerStatusService, configService, logger)
{ {
@ -30,7 +27,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
public override IIndexerRequestGenerator GetRequestGenerator() 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); var releaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
if (releaseInfo != null) if (releaseInfo != null)

@ -25,7 +25,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse) public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{ {
var results = new List<ReleaseInfo>(); var releaseInfos = new List<ReleaseInfo>();
var indexerHttpResponse = indexerResponse.HttpResponse; var indexerHttpResponse = indexerResponse.HttpResponse;
switch (indexerHttpResponse.StatusCode) switch (indexerHttpResponse.StatusCode)
@ -69,60 +69,71 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
if (jsonResponse.Result.Results == 0 || jsonResponse.Result?.Torrents?.Values == null) if (jsonResponse.Result.Results == 0 || jsonResponse.Result?.Torrents?.Values == null)
{ {
return results; return releaseInfos;
} }
var protocol = indexerResponse.HttpRequest.Url.Scheme + ":"; var protocol = indexerResponse.HttpRequest.Url.Scheme + ":";
foreach (var torrent in jsonResponse.Result.Torrents.Values) foreach (var torrent in jsonResponse.Result.Torrents.Values)
{ {
var torrentInfo = new TorrentInfo(); var flags = new HashSet<IndexerFlag>();
torrentInfo.Guid = string.Format("BTN-{0}", torrent.TorrentID); if (torrent.Origin.ToUpperInvariant() == "INTERNAL")
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)
{ {
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); if (torrent.TvrageID is > 0)
{
//torrentInfo.MagnetUrl = releaseInfo.TvRageId = torrent.TvrageID.Value;
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;
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 // 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<IndexerCategory> { NewznabStandardCategory.TV }; releaseInfo.Categories = new List<IndexerCategory> { NewznabStandardCategory.TV };
} }
results.Add(torrentInfo); releaseInfos.Add(releaseInfo);
} }
return results; return releaseInfos;
} }
private string CleanReleaseName(string releaseName) private string CleanReleaseName(string releaseName)

Loading…
Cancel
Save