New: Added search support to Nyaa

pull/4205/head
Bogdan 1 year ago
parent 09dcbf2618
commit b9a5ff55ad

@ -10,7 +10,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
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 override int PageSize => 75;
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)

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
@ -13,8 +14,8 @@ namespace NzbDrone.Core.Indexers.Nyaa
public NyaaRequestGenerator() public NyaaRequestGenerator()
{ {
MaxPages = 30; MaxPages = 3;
PageSize = 100; PageSize = 75;
} }
public virtual IndexerPageableRequestChain GetRecentRequests() public virtual IndexerPageableRequestChain GetRecentRequests()
@ -28,12 +29,25 @@ namespace NzbDrone.Core.Indexers.Nyaa
public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria) public virtual IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchCriteria)
{ {
throw new System.NotImplementedException(); var pageableRequests = new IndexerPageableRequestChain();
var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim();
var albumQuery = searchCriteria.CleanAlbumQuery.Replace("+", " ").Trim();
pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery($"{artistQuery} {albumQuery}")));
return pageableRequests;
} }
public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria) public virtual IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria searchCriteria)
{ {
throw new System.NotImplementedException(); var pageableRequests = new IndexerPageableRequestChain();
var artistQuery = searchCriteria.CleanArtistQuery.Replace("+", " ").Trim();
pageableRequests.Add(GetPagedRequests(MaxPages, PrepareQuery(artistQuery)));
return pageableRequests;
} }
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string term) private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string term)
@ -62,7 +76,7 @@ namespace NzbDrone.Core.Indexers.Nyaa
private string PrepareQuery(string query) private string PrepareQuery(string query)
{ {
return query.Replace(' ', '+'); return Uri.EscapeDataString(query);
} }
} }
} }

Loading…
Cancel
Save