|
|
@ -22,29 +22,43 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
|
|
|
|
_rateLimit = rateLimit;
|
|
|
|
_rateLimit = rateLimit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetRequest(string term, int[] categories, string imdbId = null, int? tmdbId = null, int? tvdbId = null)
|
|
|
|
private IEnumerable<IndexerRequest> GetRequest(bool isRssSearch, string term, int[] categories, string imdbId = null, int? tmdbId = null, int? tvdbId = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl.Trim('/'))
|
|
|
|
var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl.Trim('/'))
|
|
|
|
.Resource("/pubapi_v2.php")
|
|
|
|
.Resource("/pubapi_v2.php")
|
|
|
|
.AddQueryParam("mode", "search")
|
|
|
|
.AddQueryParam("limit", "100")
|
|
|
|
|
|
|
|
.AddQueryParam("token", _tokenProvider.GetToken(Settings, _rateLimit))
|
|
|
|
|
|
|
|
.AddQueryParam("format", "json_extended")
|
|
|
|
|
|
|
|
.AddQueryParam("app_id", $"rralworP_{BuildInfo.Version}")
|
|
|
|
.Accept(HttpAccept.Json);
|
|
|
|
.Accept(HttpAccept.Json);
|
|
|
|
|
|
|
|
|
|
|
|
if (imdbId.IsNotNullOrWhiteSpace())
|
|
|
|
if (isRssSearch)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
requestBuilder.AddQueryParam("search_imdb", imdbId);
|
|
|
|
requestBuilder
|
|
|
|
|
|
|
|
.AddQueryParam("mode", "list")
|
|
|
|
|
|
|
|
.WithRateLimit(31);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tmdbId.HasValue && tmdbId > 0)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
requestBuilder.AddQueryParam("search_themoviedb", tmdbId);
|
|
|
|
requestBuilder.AddQueryParam("mode", "search");
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (tvdbId.HasValue && tvdbId > 0)
|
|
|
|
if (imdbId.IsNotNullOrWhiteSpace())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
requestBuilder.AddQueryParam("search_tvdb", tvdbId);
|
|
|
|
requestBuilder.AddQueryParam("search_imdb", imdbId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (tmdbId.HasValue && tmdbId > 0)
|
|
|
|
if (term.IsNotNullOrWhiteSpace())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
requestBuilder.AddQueryParam("search_themoviedb", tmdbId);
|
|
|
|
requestBuilder.AddQueryParam("search_string", $"{term}");
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (tvdbId.HasValue && tvdbId > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("search_tvdb", tvdbId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (term.IsNotNullOrWhiteSpace())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("search_string", $"{term}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!Settings.RankedOnly)
|
|
|
|
if (!Settings.RankedOnly)
|
|
|
@ -53,17 +67,13 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var cats = Categories.MapTorznabCapsToTrackers(categories);
|
|
|
|
var cats = Categories.MapTorznabCapsToTrackers(categories);
|
|
|
|
|
|
|
|
if (cats == null || !cats.Any())
|
|
|
|
if (cats != null && cats.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var categoryParam = string.Join(";", cats.Distinct());
|
|
|
|
// default to all, without specifying it some categories are missing (e.g. games), see #4146
|
|
|
|
requestBuilder.AddQueryParam("category", categoryParam);
|
|
|
|
cats = Categories.GetTrackerCategories();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("limit", "100");
|
|
|
|
requestBuilder.AddQueryParam("category", string.Join(";", cats.Distinct()));
|
|
|
|
requestBuilder.AddQueryParam("token", _tokenProvider.GetToken(Settings, _rateLimit));
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("format", "json_extended");
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("app_id", $"rralworP_{BuildInfo.Version}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(requestBuilder.Build());
|
|
|
|
yield return new IndexerRequest(requestBuilder.Build());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,35 +81,35 @@ namespace NzbDrone.Core.Indexers.Definitions.Rarbg
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.SanitizedSearchTerm, searchCriteria.Categories, searchCriteria.FullImdbId, searchCriteria.TmdbId));
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.IsRssSearch, searchCriteria.SanitizedSearchTerm, searchCriteria.Categories, searchCriteria.FullImdbId, searchCriteria.TmdbId));
|
|
|
|
return pageableRequests;
|
|
|
|
return pageableRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MusicSearchCriteria searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.IsRssSearch, searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
return pageableRequests;
|
|
|
|
return pageableRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(TvSearchCriteria searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.SanitizedTvSearchString, searchCriteria.Categories, searchCriteria.FullImdbId, tvdbId: searchCriteria.TvdbId));
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.IsRssSearch, searchCriteria.SanitizedTvSearchString, searchCriteria.Categories, searchCriteria.FullImdbId, tvdbId: searchCriteria.TvdbId));
|
|
|
|
return pageableRequests;
|
|
|
|
return pageableRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BookSearchCriteria searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.IsRssSearch, searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
return pageableRequests;
|
|
|
|
return pageableRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
pageableRequests.Add(GetRequest(searchCriteria.IsRssSearch, searchCriteria.SanitizedSearchTerm, searchCriteria.Categories));
|
|
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
return pageableRequests;
|
|
|
|
}
|
|
|
|
}
|
|
|
|