@ -8,8 +8,8 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions ;
using NzbDrone.Core.Indexers.Exceptions ;
using NzbDrone.Core.Parser.Model ;
using NzbDrone.Core.Parser.Model ;
namespace NzbDrone.Core.Indexers. FileList
namespace NzbDrone.Core.Indexers. Definitions. FileList;
{
public class FileListParser : IParseIndexerResponse
public class FileListParser : IParseIndexerResponse
{
{
private readonly FileListSettings _settings ;
private readonly FileListSettings _settings ;
@ -23,8 +23,6 @@ namespace NzbDrone.Core.Indexers.FileList
public IList < ReleaseInfo > ParseResponse ( IndexerResponse indexerResponse )
public IList < ReleaseInfo > ParseResponse ( IndexerResponse indexerResponse )
{
{
var torrentInfos = new List < ReleaseInfo > ( ) ;
if ( indexerResponse . HttpResponse . StatusCode ! = HttpStatusCode . OK )
if ( indexerResponse . HttpResponse . StatusCode ! = HttpStatusCode . OK )
{
{
throw new IndexerException ( indexerResponse , "Unexpected response status {0} code from API request" , indexerResponse . HttpResponse . StatusCode ) ;
throw new IndexerException ( indexerResponse , "Unexpected response status {0} code from API request" , indexerResponse . HttpResponse . StatusCode ) ;
@ -35,45 +33,52 @@ namespace NzbDrone.Core.Indexers.FileList
throw new IndexerException ( indexerResponse , $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}" ) ;
throw new IndexerException ( indexerResponse , $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from API request, expected {HttpAccept.Json.Value}" ) ;
}
}
var queryResults = JsonConvert . DeserializeObject < List < FileListTorrent > > ( indexerResponse . Content ) ;
var releaseInfos = new List < ReleaseInfo > ( ) ;
foreach ( var result in queryResults )
var results = JsonConvert . DeserializeObject < List < FileListTorrent > > ( indexerResponse . Content ) ;
foreach ( var row in results )
{
// skip non-freeleech results when freeleech only is set
if ( _settings . FreeleechOnly & & ! row . FreeLeech )
{
{
var id = result . Id ;
continue ;
}
var flags = new HashSet < IndexerFlag > ( ) ;
var id = row . Id ;
if ( result . Internal )
var flags = new HashSet < IndexerFlag > ( ) ;
if ( row . Internal )
{
{
flags . Add ( IndexerFlag . Internal ) ;
flags . Add ( IndexerFlag . Internal ) ;
}
}
var imdbId = 0 ;
var imdbId = 0 ;
if ( result . ImdbId ! = null & & result . ImdbId . Length > 2 )
if ( row . ImdbId ! = null & & row . ImdbId . Length > 2 )
{
{
imdbId = int . Parse ( r esult . ImdbId . Substring ( 2 ) ) ;
imdbId = int . Parse ( r ow . ImdbId . Substring ( 2 ) ) ;
}
}
var downloadVolumeFactor = r esult . FreeLeech ? 0 : 1 ;
var downloadVolumeFactor = r ow . FreeLeech ? 0 : 1 ;
var uploadVolumeFactor = r esult . DoubleUp ? 2 : 1 ;
var uploadVolumeFactor = r ow . DoubleUp ? 2 : 1 ;
torrent Infos. Add ( new TorrentInfo
release Infos. Add ( new TorrentInfo
{
{
Guid = string . Format ( "FileList-{0}" , id ) ,
Guid = string . Format ( "FileList-{0}" , id ) ,
Title = result . Name ,
Title = row . Name ,
Size = result . Size ,
Size = row . Size ,
Categories = _categories . MapTrackerCatDescToNewznab ( r esult . Category ) ,
Categories = _categories . MapTrackerCatDescToNewznab ( r ow . Category ) ,
DownloadUrl = GetDownloadUrl ( id ) ,
DownloadUrl = GetDownloadUrl ( id ) ,
InfoUrl = GetInfoUrl ( id ) ,
InfoUrl = GetInfoUrl ( id ) ,
Seeders = result . Seeders ,
Seeders = row . Seeders ,
Peers = result . Leechers + result . Seeders ,
Peers = row . Leechers + row . Seeders ,
PublishDate = DateTime . Parse ( r esult . UploadDate + " +0200" , CultureInfo . InvariantCulture , DateTimeStyles . AdjustToUniversal ) ,
PublishDate = DateTime . Parse ( r ow . UploadDate + " +0200" , CultureInfo . InvariantCulture , DateTimeStyles . AdjustToUniversal ) ,
Description = result . SmallDescription ,
Description = row . SmallDescription ,
Genres = result . SmallDescription . Split ( ',' , StringSplitOptions . TrimEntries | StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ,
Genres = row . SmallDescription . Split ( ',' , StringSplitOptions . TrimEntries | StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ,
ImdbId = imdbId ,
ImdbId = imdbId ,
IndexerFlags = flags ,
IndexerFlags = flags ,
Files = ( int ) r esult . Files ,
Files = ( int ) r ow . Files ,
Grabs = ( int ) r esult . TimesCompleted ,
Grabs = ( int ) r ow . TimesCompleted ,
DownloadVolumeFactor = downloadVolumeFactor ,
DownloadVolumeFactor = downloadVolumeFactor ,
UploadVolumeFactor = uploadVolumeFactor ,
UploadVolumeFactor = uploadVolumeFactor ,
MinimumRatio = 1 ,
MinimumRatio = 1 ,
@ -81,7 +86,7 @@ namespace NzbDrone.Core.Indexers.FileList
} ) ;
} ) ;
}
}
return torrent Infos. ToArray ( ) ;
return release Infos. ToArray ( ) ;
}
}
public Action < IDictionary < string , string > , DateTime ? > CookiesUpdater { get ; set ; }
public Action < IDictionary < string , string > , DateTime ? > CookiesUpdater { get ; set ; }
@ -105,4 +110,3 @@ namespace NzbDrone.Core.Indexers.FileList
return url . FullUri ;
return url . FullUri ;
}
}
}
}
}