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;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
2017-10-29 06:21:18 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2017-04-15 08:45:10 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-02-28 21:25:23 +00:00
|
|
|
using AngleSharp.Html.Parser;
|
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
|
|
|
{
|
2017-07-10 20:58:44 +00:00
|
|
|
public class FileList : BaseWebIndexer
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-03-03 20:15:07 +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/",
|
|
|
|
"http://flro.org/",
|
2018-04-11 16:06:18 +00:00
|
|
|
};
|
|
|
|
|
2020-02-25 16:08:03 +00:00
|
|
|
private string LoginUrl => SiteLink + "takelogin.php";
|
|
|
|
private string BrowseUrl => SiteLink + "browse.php";
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
private new ConfigurationDataFileList configData
|
2017-04-15 08:45:10 +00:00
|
|
|
{
|
2020-02-25 16:08:03 +00:00
|
|
|
get => (ConfigurationDataFileList)base.configData;
|
|
|
|
set => base.configData = value;
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
public FileList(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2017-04-15 08:45:10 +00:00
|
|
|
: base(name: "FileList",
|
|
|
|
description: "The best Romanian site.",
|
2020-04-13 04:55:42 +00:00
|
|
|
link: "https://filelist.io/",
|
2017-04-15 08:45:10 +00:00
|
|
|
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
|
2017-07-10 20:58:44 +00:00
|
|
|
configService: configService,
|
2017-04-15 08:45:10 +00:00
|
|
|
client: wc,
|
|
|
|
logger: l,
|
|
|
|
p: ps,
|
|
|
|
configData: new ConfigurationDataFileList())
|
|
|
|
{
|
2017-11-05 09:42:03 +00:00
|
|
|
Encoding = Encoding.UTF8;
|
2017-04-15 08:45:10 +00:00
|
|
|
Language = "ro-ro";
|
|
|
|
Type = "private";
|
|
|
|
|
2019-05-11 03:27:25 +00:00
|
|
|
TorznabCaps.SupportsImdbMovieSearch = true;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(24, TorznabCatType.TVAnime, "Anime");
|
|
|
|
AddCategoryMapping(11, TorznabCatType.Audio, "Audio");
|
|
|
|
AddCategoryMapping(15, TorznabCatType.TV, "Desene");
|
|
|
|
AddCategoryMapping(18, TorznabCatType.Other, "Diverse");
|
|
|
|
AddCategoryMapping(16, TorznabCatType.Books, "Docs");
|
|
|
|
AddCategoryMapping(25, TorznabCatType.Movies3D, "Filme 3D");
|
|
|
|
AddCategoryMapping(6, TorznabCatType.MoviesHD, "Filme 4K");
|
|
|
|
AddCategoryMapping(26, TorznabCatType.MoviesBluRay, "Filme 4K Blu-Ray");
|
|
|
|
AddCategoryMapping(20, TorznabCatType.MoviesBluRay, "Filme Blu-Ray");
|
|
|
|
AddCategoryMapping(2, TorznabCatType.MoviesDVD, "Filme DVD");
|
|
|
|
AddCategoryMapping(3, TorznabCatType.MoviesForeign, "Filme DVD-RO");
|
|
|
|
AddCategoryMapping(4, TorznabCatType.MoviesHD, "Filme HD");
|
2017-10-17 10:08:52 +00:00
|
|
|
AddCategoryMapping(19, TorznabCatType.MoviesForeign, "Filme HD-RO");
|
2017-10-29 06:21:18 +00:00
|
|
|
AddCategoryMapping(1, TorznabCatType.MoviesSD, "Filme SD");
|
|
|
|
AddCategoryMapping(5, TorznabCatType.AudioLossless, "FLAC");
|
|
|
|
AddCategoryMapping(10, TorznabCatType.Console, "Jocuri Console");
|
|
|
|
AddCategoryMapping(9, TorznabCatType.PCGames, "Jocuri PC");
|
|
|
|
AddCategoryMapping(17, TorznabCatType.PC, "Linux");
|
|
|
|
AddCategoryMapping(22, TorznabCatType.PCPhoneOther, "Mobile");
|
|
|
|
AddCategoryMapping(8, TorznabCatType.PC, "Programe");
|
|
|
|
AddCategoryMapping(27, TorznabCatType.TVHD, "Seriale 4K");
|
|
|
|
AddCategoryMapping(21, TorznabCatType.TVHD, "Seriale HD");
|
|
|
|
AddCategoryMapping(23, TorznabCatType.TVSD, "Seriale SD");
|
|
|
|
AddCategoryMapping(13, TorznabCatType.TVSport, "Sport");
|
|
|
|
AddCategoryMapping(12, TorznabCatType.AudioVideo, "Videoclip");
|
|
|
|
AddCategoryMapping(7, TorznabCatType.XXX, "XXX");
|
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-03-03 20:15:07 +00:00
|
|
|
var responseFirstPage = await RequestStringWithCookiesAndRetry(SiteLink + "login.php?returnto=%2F", "");
|
2020-02-28 21:25:23 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var domFirstPage = parser.ParseDocument(responseFirstPage.Content);
|
|
|
|
var validator = domFirstPage.QuerySelector("input[name =\"validator\"]").GetAttribute("value");
|
2017-04-15 08:45:10 +00:00
|
|
|
var pairs = new Dictionary<string, string> {
|
2020-01-05 06:12:19 +00:00
|
|
|
{ "validator", validator},
|
2017-04-15 08:45:10 +00:00
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
{ "password", configData.Password.Value }
|
|
|
|
};
|
|
|
|
|
2020-01-05 06:12:19 +00:00
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, responseFirstPage.Cookies, true, null, LoginUrl);
|
2017-04-15 08:45:10 +00:00
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
|
|
|
{
|
2020-02-28 21:25:23 +00:00
|
|
|
var dom = parser.ParseDocument(result.Content);
|
|
|
|
var errorMessage = dom.QuerySelector(".main").TextContent.Trim();
|
2017-04-15 08:45:10 +00:00
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
});
|
|
|
|
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>();
|
|
|
|
var searchUrl = BrowseUrl;
|
|
|
|
var searchString = query.GetQueryString();
|
2020-03-25 17:54:51 +00:00
|
|
|
var cat = MapTorznabCapsToTrackers(query).FirstIfSingleOrDefault("0");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
|
|
|
|
if (query.ImdbID != null)
|
|
|
|
queryCollection.Add("search", query.ImdbID);
|
|
|
|
else if (!string.IsNullOrWhiteSpace(searchString))
|
|
|
|
queryCollection.Add("search", searchString);
|
|
|
|
|
|
|
|
queryCollection.Add("cat", cat);
|
2019-05-05 19:37:49 +00:00
|
|
|
queryCollection.Add("searchin", "1");
|
|
|
|
queryCollection.Add("sort", "2");
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
|
|
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
2017-10-29 06:21:18 +00:00
|
|
|
|
2017-07-06 18:31:07 +00:00
|
|
|
// Occasionally the cookies become invalid, login again if that happens
|
|
|
|
if (response.IsRedirect)
|
|
|
|
{
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
|
|
|
}
|
|
|
|
|
2017-04-15 08:45:10 +00:00
|
|
|
var results = response.Content;
|
|
|
|
try
|
|
|
|
{
|
2020-02-28 21:25:23 +00:00
|
|
|
var parser = new HtmlParser();
|
|
|
|
var dom = parser.ParseDocument(results);
|
|
|
|
var globalFreeLeech = dom.QuerySelectorAll("div.globalFreeLeech").Any();
|
|
|
|
var rows = dom.QuerySelectorAll(".torrentrow");
|
2017-04-15 08:45:10 +00:00
|
|
|
foreach (var row in rows)
|
|
|
|
{
|
|
|
|
var release = new ReleaseInfo();
|
2020-03-03 20:15:07 +00:00
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
var qTitleLink = row.QuerySelector(".torrenttable:nth-of-type(2) a");
|
|
|
|
release.Title = row.QuerySelector(".torrenttable:nth-of-type(2) b").TextContent;
|
|
|
|
var longtitle = row.QuerySelector(".torrenttable:nth-of-type(2) a[title]").GetAttribute("title");
|
2017-08-11 13:57:55 +00:00
|
|
|
if (!string.IsNullOrEmpty(longtitle) && !longtitle.Contains("<")) // releases with cover image have no full title
|
|
|
|
release.Title = longtitle;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
|
|
|
if (query.ImdbID == null && !query.MatchQueryStringAND(release.Title))
|
2017-10-29 06:21:18 +00:00
|
|
|
continue;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-03-03 20:15:07 +00:00
|
|
|
release.Description = row.QuerySelector(".torrenttable:nth-of-type(2) > span > font.small")?.TextContent;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
var tooltip = qTitleLink.GetAttribute("title");
|
2017-04-15 08:45:10 +00:00
|
|
|
if (!string.IsNullOrEmpty(tooltip))
|
|
|
|
{
|
2020-03-03 20:15:07 +00:00
|
|
|
var imgRegexp = new Regex("src='(.*?)'");
|
|
|
|
var imgRegexpMatch = imgRegexp.Match(tooltip);
|
|
|
|
if (imgRegexpMatch.Success)
|
|
|
|
release.BannerUrl = new Uri(imgRegexpMatch.Groups[1].Value);
|
2017-04-15 08:45:10 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
release.Guid = new Uri(SiteLink + qTitleLink.GetAttribute("href"));
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Comments = release.Guid;
|
|
|
|
|
|
|
|
//22:05:3716/02/2013
|
2020-02-28 21:25:23 +00:00
|
|
|
var dateStr = row.QuerySelector(".torrenttable:nth-of-type(6)").TextContent.Trim() + " +0200";
|
2017-04-15 08:45:10 +00:00
|
|
|
release.PublishDate = DateTime.ParseExact(dateStr, "H:mm:ssdd/MM/yyyy zzz", CultureInfo.InvariantCulture);
|
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
var qLink = row.QuerySelector("a[href^=\"download.php?id=\"]");
|
|
|
|
release.Link = new Uri(SiteLink + qLink.GetAttribute("href").Replace("&usetoken=1", ""));
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
var sizeStr = row.QuerySelector(".torrenttable:nth-of-type(7)").TextContent.Trim();
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
|
|
|
|
2020-03-03 20:15:07 +00:00
|
|
|
var grabs = row.QuerySelector(".torrenttable:nth-of-type(8)").TextContent.Replace("times", "").Trim();
|
|
|
|
release.Grabs = ParseUtil.CoerceLong(grabs);
|
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.QuerySelector(".torrenttable:nth-of-type(9)").TextContent.Trim());
|
|
|
|
release.Peers = ParseUtil.CoerceInt(row.QuerySelector(".torrenttable:nth-of-type(10)").TextContent.Trim()) + release.Seeders;
|
2017-04-15 08:45:10 +00:00
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
var catId = row.QuerySelector(".torrenttable:nth-of-type(1) a").GetAttribute("href").Substring(15);
|
2017-04-15 08:45:10 +00:00
|
|
|
release.Category = MapTrackerCatToNewznab(catId);
|
|
|
|
|
2020-02-28 21:25:23 +00:00
|
|
|
if (globalFreeLeech || row.QuerySelectorAll("img[alt=\"FreeLeech\"]").Any())
|
2017-04-15 08:45:10 +00:00
|
|
|
release.DownloadVolumeFactor = 0;
|
|
|
|
else
|
|
|
|
release.DownloadVolumeFactor = 1;
|
|
|
|
|
|
|
|
release.UploadVolumeFactor = 1;
|
|
|
|
|
|
|
|
// Skip Romanian releases
|
|
|
|
if (release.Category.Contains(TorznabCatType.MoviesForeign.ID) && !configData.IncludeRomanianReleases.Value)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
OnParseError(results, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|