Fixed: (FileList) Add alternative URL and return only FL results when fl-only is set

pull/1379/head v1.1.2.2453
Bogdan 2 years ago
parent 0685c2eb04
commit 0c0cbdac2f

@ -8,7 +8,7 @@ using Moq;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.FileList; using NzbDrone.Core.Indexers.Definitions.FileList;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;

@ -3,7 +3,7 @@ using System.Linq;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.FileList; using NzbDrone.Core.Indexers.Definitions.FileList;
using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;

@ -3,12 +3,16 @@ using NLog;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
namespace NzbDrone.Core.Indexers.FileList namespace NzbDrone.Core.Indexers.Definitions.FileList;
{
public class FileList : TorrentIndexerBase<FileListSettings> public class FileList : TorrentIndexerBase<FileListSettings>
{ {
public override string Name => "FileList.io"; public override string Name => "FileList.io";
public override string[] IndexerUrls => new[] { "https://filelist.io/" }; public override string[] IndexerUrls => new[]
{
"https://filelist.io/",
"https://flro.org/"
};
public override string[] LegacyUrls => new[] { "https://filelist.io" }; public override string[] LegacyUrls => new[] { "https://filelist.io" };
public override string Description => "FileList (FL) is a ROMANIAN Private Torrent Tracker for 0DAY / GENERAL"; public override string Description => "FileList (FL) is a ROMANIAN Private Torrent Tracker for 0DAY / GENERAL";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
@ -94,4 +98,3 @@ namespace NzbDrone.Core.Indexers.FileList
return caps; return caps;
} }
} }
}

@ -1,7 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NzbDrone.Core.Indexers.FileList namespace NzbDrone.Core.Indexers.Definitions.FileList;
{
public class FileListTorrent public class FileListTorrent
{ {
public string Id { get; set; } public string Id { get; set; }
@ -26,4 +26,3 @@ namespace NzbDrone.Core.Indexers.FileList
[JsonProperty(PropertyName = "small_description")] [JsonProperty(PropertyName = "small_description")]
public string SmallDescription { get; set; } public string SmallDescription { get; set; }
} }
}

@ -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(result.ImdbId.Substring(2)); imdbId = int.Parse(row.ImdbId.Substring(2));
} }
var downloadVolumeFactor = result.FreeLeech ? 0 : 1; var downloadVolumeFactor = row.FreeLeech ? 0 : 1;
var uploadVolumeFactor = result.DoubleUp ? 2 : 1; var uploadVolumeFactor = row.DoubleUp ? 2 : 1;
torrentInfos.Add(new TorrentInfo releaseInfos.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(result.Category), Categories = _categories.MapTrackerCatDescToNewznab(row.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(result.UploadDate + " +0200", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal), PublishDate = DateTime.Parse(row.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)result.Files, Files = (int)row.Files,
Grabs = (int)result.TimesCompleted, Grabs = (int)row.TimesCompleted,
DownloadVolumeFactor = downloadVolumeFactor, DownloadVolumeFactor = downloadVolumeFactor,
UploadVolumeFactor = uploadVolumeFactor, UploadVolumeFactor = uploadVolumeFactor,
MinimumRatio = 1, MinimumRatio = 1,
@ -81,7 +86,7 @@ namespace NzbDrone.Core.Indexers.FileList
}); });
} }
return torrentInfos.ToArray(); return releaseInfos.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;
} }
} }
}

@ -6,8 +6,8 @@ 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 class FileListRequestGenerator : IIndexerRequestGenerator
{ {
public FileListSettings Settings { get; set; } public FileListSettings Settings { get; set; }
@ -151,4 +151,3 @@ namespace NzbDrone.Core.Indexers.FileList
return parameters; return parameters;
} }
} }
}

@ -3,8 +3,8 @@ using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers.Settings; using NzbDrone.Core.Indexers.Settings;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.FileList namespace NzbDrone.Core.Indexers.Definitions.FileList;
{
public class FileListSettingsValidator : NoAuthSettingsValidator<FileListSettings> public class FileListSettingsValidator : NoAuthSettingsValidator<FileListSettings>
{ {
public FileListSettingsValidator() public FileListSettingsValidator()
@ -32,4 +32,3 @@ namespace NzbDrone.Core.Indexers.FileList
return new NzbDroneValidationResult(Validator.Validate(this)); return new NzbDroneValidationResult(Validator.Validate(this));
} }
} }
}

@ -1,13 +1,10 @@
using System.Collections.Generic;
using System.Threading; using System.Threading;
using Microsoft.Extensions.Configuration;
using NLog; using NLog;
using Npgsql;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Datastore.Migration.Framework; using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Core.Indexers.FileList; using NzbDrone.Core.Indexers.Definitions.FileList;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Datastore; using NzbDrone.Test.Common.Datastore;
using Prowlarr.Http.ClientSchema; using Prowlarr.Http.ClientSchema;

Loading…
Cancel
Save