From 9dc117191e3ef0a8f888c7095b18a5f5821455b8 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 28 Nov 2023 09:22:13 +0200 Subject: [PATCH] Minor cleanup for BTN --- .../BroadcastheNet/BroadcastheNet.cs | 15 ++------ .../BroadcastheNet/BroadcastheNetParser.cs | 4 +-- .../BroadcastheNetRequestGenerator.cs | 35 ++++++++----------- .../BroadcastheNetTorrentQuery.cs | 13 +++---- 4 files changed, 25 insertions(+), 42 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs index 023dde67419..9a2e802d913 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs @@ -27,18 +27,7 @@ public BroadcastheNet(IIndexerHttpClient httpClient, IEventAggregator eventAggre public override IIndexerRequestGenerator GetRequestGenerator() { - var requestGenerator = new BroadcastheNetRequestGenerator { Settings = Settings, PageSize = PageSize, Capabilities = Capabilities }; - - var releaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id); - if (releaseInfo != null) - { - if (int.TryParse(releaseInfo.Guid.Replace("BTN-", string.Empty), out var torrentId)) - { - requestGenerator.LastRecentTorrentID = torrentId; - } - } - - return requestGenerator; + return new BroadcastheNetRequestGenerator { Settings = Settings, Capabilities = Capabilities, PageSize = PageSize }; } public override IParseIndexerResponse GetParser() @@ -62,7 +51,7 @@ private IndexerCapabilities SetCapabilities() caps.Categories.AddCategoryMapping("720p", NewznabStandardCategory.TVHD, "720p"); caps.Categories.AddCategoryMapping("1080p", NewznabStandardCategory.TVHD, "1080p"); caps.Categories.AddCategoryMapping("1080i", NewznabStandardCategory.TVHD, "1080i"); - caps.Categories.AddCategoryMapping("2160p", NewznabStandardCategory.TVHD, "2160p"); + caps.Categories.AddCategoryMapping("2160p", NewznabStandardCategory.TVUHD, "2160p"); caps.Categories.AddCategoryMapping("Portable Device", NewznabStandardCategory.TVSD, "Portable Device"); return caps; diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs index 88d66a0b2f7..394fed9ad59 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs @@ -138,9 +138,7 @@ public IList ParseResponse(IndexerResponse indexerResponse) private string CleanReleaseName(string releaseName) { - releaseName = releaseName.Replace("\\", ""); - - return releaseName; + return releaseName.Replace("\\", ""); } } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs index 17fc12a44ba..6705c977315 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetRequestGenerator.cs @@ -9,31 +9,13 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet { public class BroadcastheNetRequestGenerator : IIndexerRequestGenerator { - public int MaxPages { get; set; } - public int PageSize { get; set; } public BroadcastheNetSettings Settings { get; set; } public IndexerCapabilities Capabilities { get; set; } - - public int? LastRecentTorrentID { get; set; } + public int PageSize { get; set; } public Func> GetCookies { get; set; } public Action, DateTime?> CookiesUpdater { get; set; } - public BroadcastheNetRequestGenerator() - { - MaxPages = 10; - PageSize = 100; - } - - private IEnumerable GetPagedRequests(BroadcastheNetTorrentQuery parameters, int results, int offset) - { - var builder = new JsonRpcRequestBuilder(Settings.BaseUrl) - .Call("getTorrents", Settings.ApiKey, parameters, results, offset); - builder.SuppressHttpError = true; - - yield return new IndexerRequest(builder.Build()); - } - public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) { return new IndexerPageableRequestChain(); @@ -132,11 +114,24 @@ public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchC var btnOffset = searchCriteria.Offset.GetValueOrDefault(0); - parameters.Search = searchString.Replace(" ", "%"); + if (searchString.IsNotNullOrWhiteSpace()) + { + parameters.Search = searchString.Replace(" ", "%"); + } pageableRequests.Add(GetPagedRequests(parameters, btnResults, btnOffset)); return pageableRequests; } + + private IEnumerable GetPagedRequests(BroadcastheNetTorrentQuery parameters, int results, int offset) + { + var builder = new JsonRpcRequestBuilder(Settings.BaseUrl) + .Call("getTorrents", Settings.ApiKey, parameters, results, offset); + + builder.SuppressHttpError = true; + + yield return new IndexerRequest(builder.Build()); + } } } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetTorrentQuery.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetTorrentQuery.cs index 1180f9b6353..5cfadcef320 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetTorrentQuery.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetTorrentQuery.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace NzbDrone.Core.Indexers.BroadcastheNet { @@ -13,15 +14,15 @@ public class BroadcastheNetTorrentQuery [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string Search { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Codec { get; set; } + public IEnumerable Codec { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Container { get; set; } + public IEnumerable Container { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Source { get; set; } + public IEnumerable Source { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Resolution { get; set; } + public IEnumerable Resolution { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Origin { get; set; } + public IEnumerable Origin { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string Hash { get; set; } [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]