From 77a76fe5a123d8a1f8258db3514c093131042499 Mon Sep 17 00:00:00 2001 From: Steve Adams Date: Thu, 26 Aug 2021 13:22:04 +1000 Subject: [PATCH] New: HDBits to parse IMDB using parser utils (#454) --- .../HDBits/HDBitsRequestGenerator.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs index 35c258a6f..8c486c673 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs @@ -5,6 +5,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser; namespace NzbDrone.Core.Indexers.HDBits { @@ -17,26 +18,22 @@ namespace NzbDrone.Core.Indexers.HDBits { var pageableRequests = new IndexerPageableRequestChain(); var query = new TorrentQuery(); + var imdbId = ParseUtil.GetImdbID(searchCriteria.ImdbId).GetValueOrDefault(0); if (searchCriteria.Categories?.Length > 0) { query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray(); } - if (searchCriteria.ImdbId.IsNullOrWhiteSpace() && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) + if (imdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) { query.Search = searchCriteria.SanitizedSearchTerm; } - if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace()) + if (imdbId != 0) { - var imdbId = int.Parse(searchCriteria.ImdbId.Substring(2)); - - if (imdbId != 0) - { - query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo(); - query.ImdbInfo.Id = imdbId; - } + query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo(); + query.ImdbInfo.Id = imdbId; } pageableRequests.Add(GetRequest(query)); @@ -79,13 +76,14 @@ namespace NzbDrone.Core.Indexers.HDBits var pageableRequests = new IndexerPageableRequestChain(); var query = new TorrentQuery(); var tvdbId = searchCriteria.TvdbId.GetValueOrDefault(0); + var imdbId = ParseUtil.GetImdbID(searchCriteria.ImdbId).GetValueOrDefault(0); if (searchCriteria.Categories?.Length > 0) { query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray(); } - if (tvdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) + if (tvdbId == 0 && imdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace()) { query.Search = searchCriteria.SanitizedTvSearchString; } @@ -98,6 +96,12 @@ namespace NzbDrone.Core.Indexers.HDBits query.TvdbInfo.Episode = searchCriteria.Episode; } + if (imdbId != 0) + { + query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo(); + query.ImdbInfo.Id = imdbId; + } + pageableRequests.Add(GetRequest(query)); return pageableRequests;