2020-02-09 02:35:16 +00:00
|
|
|
using System;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Specialized;
|
2020-05-03 23:35:52 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
2018-03-10 08:05:56 +00:00
|
|
|
using Jackett.Common.Models;
|
|
|
|
using Jackett.Common.Models.IndexerConfig.Bespoke;
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
using Jackett.Common.Utils.Clients;
|
2017-10-29 06:21:18 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using NLog;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
namespace Jackett.Common.Indexers
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-05-03 23:35:52 +00:00
|
|
|
[ExcludeFromCodeCoverage]
|
2017-07-10 20:58:44 +00:00
|
|
|
public class FileList : BaseWebIndexer
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
public override string[] LegacySiteLinks { get; protected set; } =
|
|
|
|
{
|
2018-04-11 16:06:18 +00:00
|
|
|
"http://filelist.ro/",
|
2020-04-13 04:55:42 +00:00
|
|
|
"https://filelist.ro/",
|
|
|
|
"https://flro.org/",
|
2020-10-19 21:19:10 +00:00
|
|
|
"http://flro.org/"
|
2018-04-11 16:06:18 +00:00
|
|
|
};
|
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
private string ApiUrl => SiteLink + "api.php";
|
|
|
|
private string DetailsUrl => SiteLink + "details.php";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
private new ConfigurationDataFileList configData => (ConfigurationDataFileList)base.configData;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-12-11 22:14:21 +00:00
|
|
|
public FileList(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
|
|
|
|
ICacheService cs)
|
2020-05-11 19:59:28 +00:00
|
|
|
: base(id: "filelist",
|
|
|
|
name: "FileList",
|
|
|
|
description: "The best Romanian site.",
|
|
|
|
link: "https://filelist.io/",
|
|
|
|
caps: new TorznabCapabilities
|
|
|
|
{
|
2020-10-18 20:47:36 +00:00
|
|
|
TvSearchParams = new List<TvSearchParam>
|
|
|
|
{
|
|
|
|
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep
|
|
|
|
},
|
|
|
|
MovieSearchParams = new List<MovieSearchParam>
|
|
|
|
{
|
|
|
|
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
2020-10-20 00:38:27 +00:00
|
|
|
},
|
|
|
|
MusicSearchParams = new List<MusicSearchParam>
|
|
|
|
{
|
|
|
|
MusicSearchParam.Q
|
|
|
|
},
|
|
|
|
BookSearchParams = new List<BookSearchParam>
|
|
|
|
{
|
|
|
|
BookSearchParam.Q
|
2020-10-18 20:47:36 +00:00
|
|
|
}
|
2020-05-11 19:59:28 +00:00
|
|
|
},
|
|
|
|
configService: configService,
|
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
2020-12-11 22:14:21 +00:00
|
|
|
cacheService: cs,
|
2020-05-11 19:59:28 +00:00
|
|
|
configData: new ConfigurationDataFileList())
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2017-11-05 09:42:03 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2017-04-15 08:45:10 +00:00
|
|
|
Language = "ro-ro";
|
|
|
|
Type = "private";
|
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
AddCategoryMapping(1, TorznabCatType.MoviesSD, "Filme SD");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(2, TorznabCatType.MoviesDVD, "Filme DVD");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.MoviesForeign, "Filme DVD-RO");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.MoviesHD, "Filme HD");
|
|
|
|
AddCategoryMapping(5, TorznabCatType.AudioLossless, "FLAC");
|
2020-04-18 02:18:09 +00:00
|
|
|
AddCategoryMapping(6, TorznabCatType.MoviesUHD, "Filme 4K");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.XXX, "XXX");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.PC, "Programe");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(9, TorznabCatType.PCGames, "Jocuri PC");
|
2020-04-18 02:18:09 +00:00
|
|
|
AddCategoryMapping(10, TorznabCatType.Console, "Jocuri Console");
|
|
|
|
AddCategoryMapping(11, TorznabCatType.Audio, "Audio");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.AudioVideo, "Videoclip");
|
|
|
|
AddCategoryMapping(13, TorznabCatType.TVSport, "Sport");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.TV, "Desene");
|
|
|
|
AddCategoryMapping(16, TorznabCatType.Books, "Docs");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(17, TorznabCatType.PC, "Linux");
|
2020-04-18 02:18:09 +00:00
|
|
|
AddCategoryMapping(18, TorznabCatType.Other, "Diverse");
|
|
|
|
AddCategoryMapping(19, TorznabCatType.MoviesForeign, "Filme HD-RO");
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesBluRay, "Filme Blu-Ray");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(21, TorznabCatType.TVHD, "Seriale HD");
|
2020-10-28 19:00:48 +00:00
|
|
|
AddCategoryMapping(22, TorznabCatType.PCMobileOther, "Mobile");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(23, TorznabCatType.TVSD, "Seriale SD");
|
2020-04-18 02:18:09 +00:00
|
|
|
AddCategoryMapping(24, TorznabCatType.TVAnime, "Anime");
|
|
|
|
AddCategoryMapping(25, TorznabCatType.Movies3D, "Filme 3D");
|
|
|
|
AddCategoryMapping(26, TorznabCatType.MoviesBluRay, "Filme 4K Blu-Ray");
|
|
|
|
AddCategoryMapping(27, TorznabCatType.TVUHD, "Seriale 4K");
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
LoadValuesFromJson(configJson);
|
2020-04-18 02:18:09 +00:00
|
|
|
var pingResponse = await CallProviderAsync(new TorznabQuery());
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
try
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
var json = JArray.Parse(pingResponse);
|
|
|
|
if (json.Count > 0)
|
|
|
|
{
|
|
|
|
IsConfigured = true;
|
|
|
|
SaveConfig();
|
|
|
|
return IndexerConfigurationStatus.Completed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw new ExceptionWithConfigData(ex.Message, configData);
|
|
|
|
}
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
}
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
|
|
|
var releases = new List<ReleaseInfo>();
|
2020-04-18 02:18:09 +00:00
|
|
|
var response = await CallProviderAsync(query);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
if (response.StartsWith("{\"error\""))
|
|
|
|
throw new ExceptionWithConfigData(response, configData);
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var json = JArray.Parse(response);
|
|
|
|
foreach (var row in json)
|
|
|
|
{
|
|
|
|
var detailsUri = new Uri(DetailsUrl + "?id=" + (string)row["id"]);
|
|
|
|
var seeders = (int)row["seeders"];
|
|
|
|
var peers = seeders + (int)row["leechers"];
|
|
|
|
var publishDate = DateTimeUtil.FromFuzzyTime((string)row["upload_date"] + " +0200");
|
|
|
|
var downloadVolumeFactor = (int)row["freeleech"] == 1 ? 0 : 1;
|
2020-04-20 23:53:21 +00:00
|
|
|
var uploadVolumeFactor = (int)row["doubleup"] == 1 ? 2 : 1;
|
2020-04-18 02:18:09 +00:00
|
|
|
var imdbId = ((JObject)row).ContainsKey("imdb") ? ParseUtil.GetImdbID((string)row["imdb"]) : null;
|
|
|
|
var link = new Uri((string)row["download_link"]);
|
2020-04-20 23:53:21 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
var release = new ReleaseInfo
|
|
|
|
{
|
|
|
|
Title = (string)row["name"],
|
2020-11-08 02:11:27 +00:00
|
|
|
Details = detailsUri,
|
2020-04-18 02:18:09 +00:00
|
|
|
Link = link,
|
|
|
|
Category = MapTrackerCatDescToNewznab((string)row["category"]),
|
|
|
|
Size = (long)row["size"],
|
|
|
|
Files = (long)row["files"],
|
|
|
|
Grabs = (long)row["times_completed"],
|
|
|
|
Seeders = seeders,
|
|
|
|
Peers = peers,
|
|
|
|
MinimumRatio = 1,
|
|
|
|
MinimumSeedTime = 172800, //48 hours
|
|
|
|
PublishDate = publishDate,
|
|
|
|
DownloadVolumeFactor = downloadVolumeFactor,
|
2020-04-20 23:53:21 +00:00
|
|
|
UploadVolumeFactor = uploadVolumeFactor,
|
2020-04-18 02:18:09 +00:00
|
|
|
Guid = detailsUri,
|
|
|
|
Imdb = imdbId
|
|
|
|
};
|
2020-04-20 23:53:21 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
releases.Add(release);
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(response, ex);
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
return releases;
|
|
|
|
}
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
private async Task<string> CallProviderAsync(TorznabQuery query)
|
|
|
|
{
|
|
|
|
var searchUrl = ApiUrl;
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
var cat = string.Join(",", MapTorznabCapsToTrackers(query));
|
|
|
|
var queryCollection = new NameValueCollection
|
|
|
|
{
|
|
|
|
{"category", cat}
|
|
|
|
};
|
2017-10-29 06:21:18 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
if (query.IsImdbQuery)
|
|
|
|
{
|
|
|
|
queryCollection.Add("type", "imdb");
|
|
|
|
queryCollection.Add("query", query.ImdbID);
|
|
|
|
queryCollection.Add("action", "search-torrents");
|
|
|
|
}
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchString))
|
2017-07-06 18:31:07 +00:00
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
queryCollection.Add("type", "name");
|
|
|
|
queryCollection.Add("query", searchString);
|
|
|
|
queryCollection.Add("action", "search-torrents");
|
2017-07-06 18:31:07 +00:00
|
|
|
}
|
2020-04-18 02:18:09 +00:00
|
|
|
else
|
|
|
|
queryCollection.Add("action", "latest-torrents");
|
2017-07-06 18:31:07 +00:00
|
|
|
|
2020-04-18 02:18:09 +00:00
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
2017-04-15 08:45:10 +00:00
|
|
|
try
|
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
var auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(configData.Username.Value + ":" + configData.Passkey.Value));
|
|
|
|
var headers = new Dictionary<string, string>
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
{"Authorization", "Basic " + auth}
|
|
|
|
};
|
2020-09-21 16:39:47 +00:00
|
|
|
var response = await RequestWithCookiesAsync(searchUrl, headers: headers);
|
2020-06-09 17:36:57 +00:00
|
|
|
return response.ContentString;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
2020-04-18 02:18:09 +00:00
|
|
|
catch (Exception inner)
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-04-18 02:18:09 +00:00
|
|
|
throw new Exception("Error calling provider filelist", inner);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|