1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Tweaked Nyaa Request Generator to avoid offset=1.

This commit is contained in:
Taloth Saldono 2016-10-10 22:34:32 +02:00
parent ff33f15bac
commit cd3b6000a0

View File

@ -51,17 +51,11 @@ public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchC
{ {
var searchTitle = PrepareQuery(queryTitle); var searchTitle = PrepareQuery(queryTitle);
pageableRequests.Add(GetPagedRequests(MaxPages, pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+{searchCriteria.AbsoluteEpisodeNumber:0}"));
string.Format("&term={0}+{1:0}",
searchTitle,
searchCriteria.AbsoluteEpisodeNumber)));
if (searchCriteria.AbsoluteEpisodeNumber < 10) if (searchCriteria.AbsoluteEpisodeNumber < 10)
{ {
pageableRequests.Add(GetPagedRequests(MaxPages, pageableRequests.Add(GetPagedRequests(MaxPages, $"{searchTitle}+{searchCriteria.AbsoluteEpisodeNumber:00}"));
string.Format("&term={0}+{1:00}",
searchTitle,
searchCriteria.AbsoluteEpisodeNumber)));
} }
} }
@ -82,19 +76,26 @@ public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearc
return pageableRequests; return pageableRequests;
} }
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string searchParameters) private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string term)
{ {
var baseUrl = string.Format("{0}/?page=rss{1}", Settings.BaseUrl.TrimEnd('/'), Settings.AdditionalParameters); var baseUrl = string.Format("{0}/?page=rss{1}", Settings.BaseUrl.TrimEnd('/'), Settings.AdditionalParameters);
if (term != null)
{
baseUrl += "&term=" + term;
}
if (PageSize == 0) if (PageSize == 0)
{ {
yield return new IndexerRequest(string.Format("{0}{1}", baseUrl, searchParameters), HttpAccept.Rss); yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
} }
else else
{ {
for (var page = 0; page < maxPages; page++) yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
for (var page = 1; page < maxPages; page++)
{ {
yield return new IndexerRequest(string.Format("{0}&offset={1}{2}", baseUrl, page + 1, searchParameters), HttpAccept.Rss); yield return new IndexerRequest($"{baseUrl}&offset={page + 1}", HttpAccept.Rss);
} }
} }
} }