mirror of https://github.com/lidarr/Lidarr
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
|
@ -10,12 +10,18 @@ namespace NzbDrone.Core.Indexers.Waffles
|
||||||
public class WafflesRequestGenerator : IIndexerRequestGenerator
|
public class WafflesRequestGenerator : IIndexerRequestGenerator
|
||||||
{
|
{
|
||||||
public WafflesSettings Settings { get; set; }
|
public WafflesSettings Settings { get; set; }
|
||||||
|
public int MaxPages { get; set; }
|
||||||
|
|
||||||
|
public WafflesRequestGenerator()
|
||||||
|
{
|
||||||
|
MaxPages = 5;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual IndexerPageableRequestChain GetRecentRequests()
|
public virtual IndexerPageableRequestChain GetRecentRequests()
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
var pageableRequests = new IndexerPageableRequestChain();
|
||||||
|
|
||||||
pageableRequests.Add(GetPagedRequests(null));
|
pageableRequests.Add(GetPagedRequests(MaxPages, null));
|
||||||
|
|
||||||
return pageableRequests;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Waffles
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
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;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
@ -63,12 +69,12 @@ namespace NzbDrone.Core.Indexers.Waffles
|
||||||
{
|
{
|
||||||
var pageableRequests = new IndexerPageableRequestChain();
|
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;
|
return pageableRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<IndexerRequest> GetPagedRequests(string query)
|
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, string query)
|
||||||
{
|
{
|
||||||
|
|
||||||
var url = new StringBuilder();
|
var url = new StringBuilder();
|
||||||
|
@ -80,7 +86,10 @@ namespace NzbDrone.Core.Indexers.Waffles
|
||||||
url.AppendFormat(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 New Issue