New: HDBits to parse IMDB using parser utils (#454)

pull/458/head
Steve Adams 3 years ago committed by GitHub
parent 1d20b9d429
commit 77a76fe5a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser;
namespace NzbDrone.Core.Indexers.HDBits namespace NzbDrone.Core.Indexers.HDBits
{ {
@ -17,27 +18,23 @@ namespace NzbDrone.Core.Indexers.HDBits
{ {
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
var query = new TorrentQuery(); var query = new TorrentQuery();
var imdbId = ParseUtil.GetImdbID(searchCriteria.ImdbId).GetValueOrDefault(0);
if (searchCriteria.Categories?.Length > 0) if (searchCriteria.Categories?.Length > 0)
{ {
query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray(); 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; query.Search = searchCriteria.SanitizedSearchTerm;
} }
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
{
var imdbId = int.Parse(searchCriteria.ImdbId.Substring(2));
if (imdbId != 0) if (imdbId != 0)
{ {
query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo(); query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo();
query.ImdbInfo.Id = imdbId; query.ImdbInfo.Id = imdbId;
} }
}
pageableRequests.Add(GetRequest(query)); pageableRequests.Add(GetRequest(query));
@ -79,13 +76,14 @@ namespace NzbDrone.Core.Indexers.HDBits
var pageableRequests = new IndexerPageableRequestChain(); var pageableRequests = new IndexerPageableRequestChain();
var query = new TorrentQuery(); var query = new TorrentQuery();
var tvdbId = searchCriteria.TvdbId.GetValueOrDefault(0); var tvdbId = searchCriteria.TvdbId.GetValueOrDefault(0);
var imdbId = ParseUtil.GetImdbID(searchCriteria.ImdbId).GetValueOrDefault(0);
if (searchCriteria.Categories?.Length > 0) if (searchCriteria.Categories?.Length > 0)
{ {
query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray(); 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; query.Search = searchCriteria.SanitizedTvSearchString;
} }
@ -98,6 +96,12 @@ namespace NzbDrone.Core.Indexers.HDBits
query.TvdbInfo.Episode = searchCriteria.Episode; query.TvdbInfo.Episode = searchCriteria.Episode;
} }
if (imdbId != 0)
{
query.ImdbInfo = query.ImdbInfo ?? new ImdbInfo();
query.ImdbInfo.Id = imdbId;
}
pageableRequests.Add(GetRequest(query)); pageableRequests.Add(GetRequest(query));
return pageableRequests; return pageableRequests;

Loading…
Cancel
Save