|
|
|
@ -8,70 +8,19 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentPotato
|
|
|
|
|
{
|
|
|
|
|
public class TorrentPotatoRequestGenerator : IIndexerRequestGenerator
|
|
|
|
|
{
|
|
|
|
|
public TorrentPotatoSettings Settings { get; set; }
|
|
|
|
|
private readonly TorrentPotatoSettings _settings;
|
|
|
|
|
|
|
|
|
|
public virtual IndexerPageableRequestChain GetRecentRequests()
|
|
|
|
|
public TorrentPotatoRequestGenerator(TorrentPotatoSettings settings)
|
|
|
|
|
{
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(GetPagedRequests("list", null, null));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetPagedRequests(string mode, int? tvdbId, string query, params object[] args)
|
|
|
|
|
{
|
|
|
|
|
var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl)
|
|
|
|
|
.Accept(HttpAccept.Json);
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("passkey", Settings.Passkey);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Settings.User))
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("user", Settings.User);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("user", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("search", "-");
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(requestBuilder.Build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> GetMovieRequest(MovieSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl)
|
|
|
|
|
.Accept(HttpAccept.Json);
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("passkey", Settings.Passkey);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Settings.User))
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("user", Settings.User);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("user", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchCriteria.ImdbId.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("imdbid", searchCriteria.ImdbId);
|
|
|
|
|
}
|
|
|
|
|
else if (searchCriteria.SearchTerm.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
//TODO: Hack for now
|
|
|
|
|
requestBuilder.AddQueryParam("search", $"{searchCriteria.SearchTerm}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(requestBuilder.Build());
|
|
|
|
|
_settings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
pageableRequests.Add(GetMovieRequest(searchCriteria));
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(BuildRequest(searchCriteria.SearchTerm, searchCriteria.ImdbId));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -92,7 +41,29 @@ namespace NzbDrone.Core.Indexers.Definitions.TorrentPotato
|
|
|
|
|
|
|
|
|
|
public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchCriteria)
|
|
|
|
|
{
|
|
|
|
|
return new IndexerPageableRequestChain();
|
|
|
|
|
var pageableRequests = new IndexerPageableRequestChain();
|
|
|
|
|
|
|
|
|
|
pageableRequests.Add(BuildRequest(searchCriteria.SearchTerm));
|
|
|
|
|
|
|
|
|
|
return pageableRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<IndexerRequest> BuildRequest(string searchTerm, string imdbId = null)
|
|
|
|
|
{
|
|
|
|
|
var requestBuilder = new HttpRequestBuilder(_settings.BaseUrl)
|
|
|
|
|
.Accept(HttpAccept.Json);
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("passkey", _settings.Passkey);
|
|
|
|
|
requestBuilder.AddQueryParam("user", _settings.User.IsNotNullOrWhiteSpace() ? _settings.User : "");
|
|
|
|
|
|
|
|
|
|
if (imdbId.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
requestBuilder.AddQueryParam("imdbid", imdbId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
requestBuilder.AddQueryParam("search", searchTerm.IsNotNullOrWhiteSpace() ? $"{searchTerm}" : " ");
|
|
|
|
|
|
|
|
|
|
yield return new IndexerRequest(requestBuilder.Build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<IDictionary<string, string>> GetCookies { get; set; }
|
|
|
|
|