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 NzbDrone.Common.Http;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.FileList;
using NzbDrone.Core.Indexers.Definitions.FileList;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;

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

@ -3,12 +3,16 @@ using NLog;
using NzbDrone.Core.Configuration;
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[] 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 Description => "FileList (FL) is a ROMANIAN Private Torrent Tracker for 0DAY / GENERAL";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
@ -93,5 +97,4 @@ namespace NzbDrone.Core.Indexers.FileList
return caps;
}
}
}

@ -1,9 +1,9 @@
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 Name { get; set; }
public long Size { get; set; }
@ -25,5 +25,4 @@ namespace NzbDrone.Core.Indexers.FileList
public string Category { get; set; }
[JsonProperty(PropertyName = "small_description")]
public string SmallDescription { get; set; }
}
}

@ -8,10 +8,10 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions;
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 IndexerCapabilitiesCategories _categories;
@ -23,8 +23,6 @@ namespace NzbDrone.Core.Indexers.FileList
public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
{
var torrentInfos = new List<ReleaseInfo>();
if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK)
{
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}");
}
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);
}
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 uploadVolumeFactor = result.DoubleUp ? 2 : 1;
var downloadVolumeFactor = row.FreeLeech ? 0 : 1;
var uploadVolumeFactor = row.DoubleUp ? 2 : 1;
torrentInfos.Add(new TorrentInfo
releaseInfos.Add(new TorrentInfo
{
Guid = string.Format("FileList-{0}", id),
Title = result.Name,
Size = result.Size,
Categories = _categories.MapTrackerCatDescToNewznab(result.Category),
Title = row.Name,
Size = row.Size,
Categories = _categories.MapTrackerCatDescToNewznab(row.Category),
DownloadUrl = GetDownloadUrl(id),
InfoUrl = GetInfoUrl(id),
Seeders = result.Seeders,
Peers = result.Leechers + result.Seeders,
PublishDate = DateTime.Parse(result.UploadDate + " +0200", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal),
Description = result.SmallDescription,
Genres = result.SmallDescription.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList(),
Seeders = row.Seeders,
Peers = row.Leechers + row.Seeders,
PublishDate = DateTime.Parse(row.UploadDate + " +0200", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal),
Description = row.SmallDescription,
Genres = row.SmallDescription.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).ToList(),
ImdbId = imdbId,
IndexerFlags = flags,
Files = (int)result.Files,
Grabs = (int)result.TimesCompleted,
Files = (int)row.Files,
Grabs = (int)row.TimesCompleted,
DownloadVolumeFactor = downloadVolumeFactor,
UploadVolumeFactor = uploadVolumeFactor,
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; }
@ -104,5 +109,4 @@ namespace NzbDrone.Core.Indexers.FileList
return url.FullUri;
}
}
}

@ -6,10 +6,10 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.IndexerSearch.Definitions;
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 IndexerCapabilities Capabilities { get; set; }
public Func<IDictionary<string, string>> GetCookies { get; set; }
@ -150,5 +150,4 @@ namespace NzbDrone.Core.Indexers.FileList
return parameters;
}
}
}

@ -3,19 +3,19 @@ using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers.Settings;
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()
{
RuleFor(c => c.Username).NotEmpty();
RuleFor(c => c.Passkey).NotEmpty();
}
}
}
public class FileListSettings : NoAuthTorrentBaseSettings
{
public class FileListSettings : NoAuthTorrentBaseSettings
{
private static readonly FileListSettingsValidator Validator = new ();
[FieldDefinition(2, Label = "Username", HelpText = "Site Username", Privacy = PrivacyLevel.UserName)]
@ -31,5 +31,4 @@ namespace NzbDrone.Core.Indexers.FileList
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}

@ -1,13 +1,10 @@
using System.Collections.Generic;
using System.Threading;
using Microsoft.Extensions.Configuration;
using NLog;
using Npgsql;
using NUnit.Framework;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
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.Datastore;
using Prowlarr.Http.ClientSchema;

Loading…
Cancel
Save