mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-17 07:49:45 +02:00
Remove unsupported pagination for Nyaa
(cherry picked from commit fef525ddb8b5f91bb36b3c9e652663fccb098a00) Closes #9582
This commit is contained in:
parent
0e7874aacf
commit
2c3ad380ef
@ -10,7 +10,6 @@ public class Nyaa : HttpIndexerBase<NyaaSettings>
|
|||||||
public override string Name => "Nyaa";
|
public override string Name => "Nyaa";
|
||||||
|
|
||||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||||
public override int PageSize => 100;
|
|
||||||
|
|
||||||
public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
||||||
: base(httpClient, indexerStatusService, configService, parsingService, logger)
|
: base(httpClient, indexerStatusService, configService, parsingService, logger)
|
||||||
@ -19,7 +18,7 @@ public Nyaa(IHttpClient httpClient, IIndexerStatusService indexerStatusService,
|
|||||||
|
|
||||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||||
{
|
{
|
||||||
return new NyaaRequestGenerator() { Settings = Settings, PageSize = PageSize };
|
return new NyaaRequestGenerator() { Settings = Settings };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IParseIndexerResponse GetParser()
|
public override IParseIndexerResponse GetParser()
|
||||||
|
@ -9,65 +9,44 @@ public class NyaaRequestGenerator : IIndexerRequestGenerator
|
|||||||
{
|
{
|
||||||
public NyaaSettings Settings { get; set; }
|
public NyaaSettings Settings { get; set; }
|
||||||
|
|
||||||
public int MaxPages { get; set; }
|
|
||||||
public int PageSize { get; set; }
|
|
||||||
|
|
||||||
public NyaaRequestGenerator()
|
|
||||||
{
|
|
||||||
MaxPages = 30;
|
|
||||||
PageSize = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages, null));
|
pageableRequests.Add(GetPagedRequests(null));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string term)
|
|
||||||
{
|
|
||||||
var baseUrl = string.Format("{0}/?page=rss{1}", Settings.BaseUrl.TrimEnd('/'), Settings.AdditionalParameters);
|
|
||||||
|
|
||||||
if (term != null)
|
|
||||||
{
|
|
||||||
baseUrl += "&term=" + term;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PageSize == 0)
|
|
||||||
{
|
|
||||||
yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
|
|
||||||
|
|
||||||
for (var page = 1; page < maxPages; page++)
|
|
||||||
{
|
|
||||||
yield return new IndexerRequest($"{baseUrl}&offset={page + 1}", HttpAccept.Rss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string PrepareQuery(string query)
|
|
||||||
{
|
|
||||||
return query.Replace(' ', '+');
|
|
||||||
}
|
|
||||||
|
|
||||||
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
|
||||||
foreach (var queryTitle in searchCriteria.SceneTitles)
|
foreach (var queryTitle in searchCriteria.SceneTitles)
|
||||||
{
|
{
|
||||||
pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery(string.Format("{0} {1}", queryTitle, searchCriteria.Movie.Year))));
|
pageableRequests.Add(GetPagedRequests(PrepareQuery($"{queryTitle} {searchCriteria.Movie.Year}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<IndexerRequest> GetPagedRequests(string term)
|
||||||
|
{
|
||||||
|
var baseUrl = $"{Settings.BaseUrl.TrimEnd('/')}/?page=rss{Settings.AdditionalParameters}";
|
||||||
|
|
||||||
|
if (term != null)
|
||||||
|
{
|
||||||
|
baseUrl += "&term=" + term;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new IndexerRequest(baseUrl, HttpAccept.Rss);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string PrepareQuery(string query)
|
||||||
|
{
|
||||||
|
return query.Replace(' ', '+');
|
||||||
|
}
|
||||||
|
|
||||||
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
||||||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user