mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-15 21:06:24 +01:00
Add Paging to Waffles Requests (#39)
* Add Paging to Waffles Requests * Make pages dynamic variable to match others
This commit is contained in:
parent
337f74a184
commit
4f61354dc5
1 changed files with 15 additions and 6 deletions
|
|
@ -10,12 +10,18 @@ namespace NzbDrone.Core.Indexers.Waffles
|
|||
public class WafflesRequestGenerator : IIndexerRequestGenerator
|
||||
{
|
||||
public WafflesSettings Settings { get; set; }
|
||||
|
||||
public int MaxPages { get; set; }
|
||||
|
||||
public WafflesRequestGenerator()
|
||||
{
|
||||
MaxPages = 5;
|
||||
}
|
||||
|
||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
||||
pageableRequests.Add(GetPagedRequests(null));
|
||||
pageableRequests.Add(GetPagedRequests(MaxPages, null));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
|
@ -54,7 +60,7 @@ public IndexerPageableRequestChain GetSearchRequests(AlbumSearchCriteria searchC
|
|||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
||||
pageableRequests.Add(GetPagedRequests(string.Format("&q=artist:{0} album:{1}",searchCriteria.Artist.Name,searchCriteria.AlbumTitle)));
|
||||
pageableRequests.Add(GetPagedRequests(MaxPages, string.Format("&q=artist:{0} album:{1}",searchCriteria.Artist.Name,searchCriteria.AlbumTitle)));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
|
@ -63,12 +69,12 @@ public IndexerPageableRequestChain GetSearchRequests(ArtistSearchCriteria search
|
|||
{
|
||||
var pageableRequests = new IndexerPageableRequestChain();
|
||||
|
||||
pageableRequests.Add(GetPagedRequests(string.Format("&q=artist:{0}", searchCriteria.Artist.Name)));
|
||||
pageableRequests.Add(GetPagedRequests(MaxPages, string.Format("&q=artist:{0}", searchCriteria.Artist.Name)));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(string query)
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string query)
|
||||
{
|
||||
|
||||
var url = new StringBuilder();
|
||||
|
|
@ -80,7 +86,10 @@ private IEnumerable<IndexerRequest> GetPagedRequests(string query)
|
|||
url.AppendFormat(query);
|
||||
}
|
||||
|
||||
yield return new IndexerRequest(url.ToString(), HttpAccept.Rss);
|
||||
for (var page = 0; page < maxPages; page++)
|
||||
{
|
||||
yield return new IndexerRequest(string.Format("{0}&p={1}", url, page), HttpAccept.Rss);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue