@ -6,149 +6,148 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.IndexerSearch.Definitions ;
using NzbDrone.Core.IndexerSearch.Definitions ;
using NzbDrone.Core.Parser ;
using NzbDrone.Core.Parser ;
namespace NzbDrone.Core.Indexers.FileList
namespace NzbDrone.Core.Indexers.Definitions.FileList ;
{
public class FileListRequestGenerator : IIndexerRequestGenerator
{
public FileListSettings Settings { get ; set ; }
public IndexerCapabilities Capabilities { get ; set ; }
public Func < IDictionary < string , string > > GetCookies { get ; set ; }
public Action < IDictionary < string , string > , DateTime ? > CookiesUpdater { get ; set ; }
public IndexerPageableRequestChain GetSearchRequests ( TvSearchCriteria searchCriteria )
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) | | searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
public class FileListRequestGenerator : IIndexerRequestGenerator
{
{
parameters . Add ( "action" , "search-torrents" ) ;
public FileListSettings Settings { get ; set ; }
public IndexerCapabilities Capabilities { get ; set ; }
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) )
public Func < IDictionary < string , string > > GetCookies { get ; set ; }
{
public Action < IDictionary < string , string > , DateTime ? > CookiesUpdater { get ; set ; }
parameters . Add ( "type" , "imdb" ) ;
parameters . Add ( "query" , searchCriteria . FullImdbId ) ;
}
else if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
if ( searchCriteria . Season . HasValue )
{
parameters . Add ( "season" , searchCriteria . Season . ToString ( ) ) ;
parameters . Add ( "episode" , searchCriteria . Episode ) ;
}
}
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
return pageableRequests ;
public IndexerPageableRequestChain GetSearchRequests ( TvSearchCriteria searchCriteria )
}
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
public virtual IndexerPageableRequestChain GetSearchRequests ( MovieSearchCriteria searchCriteria )
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) | | searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
parameters . Add ( "action" , "search-torrents" ) ;
var parameters = GetDefaultParameters ( ) ;
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) )
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) )
{
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "imdb" ) ;
parameters . Add ( "type" , "imdb" ) ;
parameters . Add ( "query" , searchCriteria . FullImdbId ) ;
parameters . Add ( "query" , searchCriteria . FullImdbId ) ;
}
}
else if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
else if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
}
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
if ( searchCriteria . Season . HasValue )
{
return pageableRequests ;
parameters . Add ( "season" , searchCriteria . Season . ToString ( ) ) ;
parameters . Add ( "episode" , searchCriteria . Episode ) ;
}
}
}
public IndexerPageableRequestChain GetSearchRequests ( MusicSearchCriteria searchCriteria )
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
return pageableRequests ;
{
}
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
public virtual IndexerPageableRequestChain GetSearchRequests ( MovieSearchCriteria searchCriteria )
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
return pageableRequests ;
if ( searchCriteria . ImdbId . IsNotNullOrWhiteSpace ( ) )
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "imdb" ) ;
parameters . Add ( "query" , searchCriteria . FullImdbId ) ;
}
}
else if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
public IndexerPageableRequestChain GetSearchRequests ( BookSearchCriteria searchCriteria )
{
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
parameters . Add ( "action" , "search-torrents" ) ;
var parameters = GetDefaultParameters ( ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
return pageableRequests ;
}
return pageableRequests ;
public IndexerPageableRequestChain GetSearchRequests ( MusicSearchCriteria searchCriteria )
}
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
public IndexerPageableRequestChain GetSearchRequests ( BasicSearchCriteria searchCriteria )
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
parameters . Add ( "action" , "search-torrents" ) ;
var parameters = GetDefaultParameters ( ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
return pageableRequests ;
}
return pageableRequests ;
public IndexerPageableRequestChain GetSearchRequests ( BookSearchCriteria searchCriteria )
}
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
private IEnumerable < IndexerRequest > GetRequest ( SearchCriteriaBase searchCriteria , NameValueCollection parameters )
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
{
if ( parameters . Get ( "action" ) is null )
parameters . Add ( "action" , "search-torrents" ) ;
{
parameters . Add ( "type" , "name" ) ;
parameters . Add ( " action", "latest-torrents" ) ;
parameters . Add ( " query", searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
}
parameters . Add ( "category" , string . Join ( "," , Capabilities . Categories . MapTorznabCapsToTrackers ( searchCriteria . Categories ) ) ) ;
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
var searchUrl = $"{Settings.BaseUrl.TrimEnd('/')}/api.php?{parameters.GetQueryString()}" ;
return pageableRequests ;
}
yield return new IndexerRequest ( searchUrl , HttpAccept . Json ) ;
public IndexerPageableRequestChain GetSearchRequests ( BasicSearchCriteria searchCriteria )
{
var pageableRequests = new IndexerPageableRequestChain ( ) ;
var parameters = GetDefaultParameters ( ) ;
if ( searchCriteria . SearchTerm . IsNotNullOrWhiteSpace ( ) )
{
parameters . Add ( "action" , "search-torrents" ) ;
parameters . Add ( "type" , "name" ) ;
parameters . Add ( "query" , searchCriteria . SanitizedSearchTerm . Trim ( ) ) ;
}
}
private NameValueCollection GetDefaultParameters ( )
pageableRequests . Add ( GetRequest ( searchCriteria , parameters ) ) ;
return pageableRequests ;
}
private IEnumerable < IndexerRequest > GetRequest ( SearchCriteriaBase searchCriteria , NameValueCollection parameters )
{
if ( parameters . Get ( "action" ) is null )
{
{
var parameters = new NameValueCollection
parameters . Add ( "action" , "latest-torrents" ) ;
{
}
{ "username" , Settings . Username . Trim ( ) } ,
{ "passkey" , Settings . Passkey . Trim ( ) }
} ;
if ( Settings . FreeleechOnly )
parameters . Add ( "category" , string . Join ( "," , Capabilities . Categories . MapTorznabCapsToTrackers ( searchCriteria . Categories ) ) ) ;
{
parameters . Add ( "freeleech" , "1" ) ;
var searchUrl = $"{Settings.BaseUrl.TrimEnd('/')}/api.php?{parameters.GetQueryString()}" ;
}
return parameters ;
yield return new IndexerRequest ( searchUrl , HttpAccept . Json ) ;
}
private NameValueCollection GetDefaultParameters ( )
{
var parameters = new NameValueCollection
{
{ "username" , Settings . Username . Trim ( ) } ,
{ "passkey" , Settings . Passkey . Trim ( ) }
} ;
if ( Settings . FreeleechOnly )
{
parameters . Add ( "freeleech" , "1" ) ;
}
}
return parameters ;
}
}
}
}