|
|
|
@ -21,12 +21,8 @@ namespace NzbDrone.Core.Indexers.Definitions.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();
|
|
|
|
|
}
|
|
|
|
|
var imdbId = ParseUtil.GetImdbId(searchCriteria.ImdbId).GetValueOrDefault(0);
|
|
|
|
|
|
|
|
|
|
if (imdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
@ -39,37 +35,11 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
|
|
|
|
query.ImdbInfo.Id = imdbId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(GetRequest(query));
|
|
|
|
|
pageableRequests.Add(GetRequest(query, searchCriteria));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
|
|
|
|
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetRequest(TorrentQuery query)
|
|
|
|
|
{
|
|
|
|
|
var request = new HttpRequestBuilder(Settings.BaseUrl)
|
|
|
|
|
.Resource("/api/torrents")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
request.Method = HttpMethod.Post;
|
|
|
|
|
const string appJson = "application/json";
|
|
|
|
|
request.Headers.Accept = appJson;
|
|
|
|
|
request.Headers.ContentType = appJson;
|
|
|
|
|
|
|
|
|
|
query.Username = Settings.Username;
|
|
|
|
|
query.Passkey = Settings.ApiKey;
|
|
|
|
|
|
|
|
|
|
query.Codec = Settings.Codecs.ToArray();
|
|
|
|
|
query.Medium = Settings.Mediums.ToArray();
|
|
|
|
|
|
|
|
|
|
request.SetContent(query.ToJson());
|
|
|
|
|
request.ContentSummary = query.ToJson(Formatting.None);
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
return new IndexerPageableRequestChain();
|
|
|
|
@ -79,14 +49,10 @@ namespace NzbDrone.Core.Indexers.Definitions.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 && imdbId == 0 && searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
query.Search = searchCriteria.SanitizedTvSearchString;
|
|
|
|
@ -114,7 +80,7 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
|
|
|
|
query.ImdbInfo.Id = imdbId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(GetRequest(query));
|
|
|
|
|
pageableRequests.Add(GetRequest(query, searchCriteria));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
@ -129,19 +95,56 @@ namespace NzbDrone.Core.Indexers.Definitions.HDBits
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
var query = new TorrentQuery();
|
|
|
|
|
|
|
|
|
|
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
query.Search = searchCriteria.SanitizedSearchTerm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(GetRequest(query, searchCriteria));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
|
|
|
|
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetRequest(TorrentQuery query, SearchCriteriaBase searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var request = new HttpRequestBuilder(Settings.BaseUrl)
|
|
|
|
|
.Resource("/api/torrents")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
request.Method = HttpMethod.Post;
|
|
|
|
|
const string appJson = "application/json";
|
|
|
|
|
request.Headers.Accept = appJson;
|
|
|
|
|
request.Headers.ContentType = appJson;
|
|
|
|
|
|
|
|
|
|
query.Username = Settings.Username;
|
|
|
|
|
query.Passkey = Settings.ApiKey;
|
|
|
|
|
|
|
|
|
|
query.Codec = Settings.Codecs.ToArray();
|
|
|
|
|
query.Medium = Settings.Mediums.ToArray();
|
|
|
|
|
|
|
|
|
|
if (searchCriteria.Categories?.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
query.Category = Capabilities.Categories.MapTorznabCapsToTrackers(searchCriteria.Categories).Select(int.Parse).ToArray();
|
|
|
|
|
query.Category = Capabilities.Categories
|
|
|
|
|
.MapTorznabCapsToTrackers(searchCriteria.Categories)
|
|
|
|
|
.Distinct()
|
|
|
|
|
.Select(int.Parse)
|
|
|
|
|
.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
|
|
|
query.Limit = 100;
|
|
|
|
|
|
|
|
|
|
if (searchCriteria.Limit is > 0 && searchCriteria.Offset is > 0)
|
|
|
|
|
{
|
|
|
|
|
query.Search = searchCriteria.SanitizedSearchTerm;
|
|
|
|
|
query.Page = (int)(searchCriteria.Offset / searchCriteria.Limit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(GetRequest(query));
|
|
|
|
|
request.SetContent(query.ToJson());
|
|
|
|
|
request.ContentSummary = query.ToJson(Formatting.None);
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
yield return new IndexerRequest(request);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|