Filelist: fix error caused by #7360 and added grabs. Resolves #7474 (#7483)

This commit is contained in:
Diego Heras
2020-03-03 21:15:07 +01:00
committed by GitHub
parent 77837b7483
commit 8bd74a2cc9

View File

@@ -6,7 +6,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using AngleSharp.Dom;
using AngleSharp.Html.Parser; using AngleSharp.Html.Parser;
using Jackett.Common.Models; using Jackett.Common.Models;
using Jackett.Common.Models.IndexerConfig.Bespoke; using Jackett.Common.Models.IndexerConfig.Bespoke;
@@ -20,7 +19,7 @@ namespace Jackett.Common.Indexers
{ {
public class FileList : BaseWebIndexer public class FileList : BaseWebIndexer
{ {
public override string[] LegacySiteLinks { get; protected set; } = new string[] { public override string[] LegacySiteLinks { get; protected set; } = {
"http://filelist.ro/", "http://filelist.ro/",
}; };
@@ -81,7 +80,7 @@ namespace Jackett.Common.Indexers
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson) public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
{ {
LoadValuesFromJson(configJson); LoadValuesFromJson(configJson);
var responseFirstPage = await RequestStringWithCookiesAndRetry(SiteLink + "login.php?returnto=%2F", "", null); var responseFirstPage = await RequestStringWithCookiesAndRetry(SiteLink + "login.php?returnto=%2F", "");
var parser = new HtmlParser(); var parser = new HtmlParser();
var domFirstPage = parser.ParseDocument(responseFirstPage.Content); var domFirstPage = parser.ParseDocument(responseFirstPage.Content);
var validator = domFirstPage.QuerySelector("input[name =\"validator\"]").GetAttribute("value"); var validator = domFirstPage.QuerySelector("input[name =\"validator\"]").GetAttribute("value");
@@ -110,20 +109,14 @@ namespace Jackett.Common.Indexers
var cats = MapTorznabCapsToTrackers(query); var cats = MapTorznabCapsToTrackers(query);
var cat = "0"; var cat = "0";
if (cats.Count == 1) if (cats.Count == 1)
{
cat = cats[0]; cat = cats[0];
}
var queryCollection = new NameValueCollection(); var queryCollection = new NameValueCollection();
if (query.ImdbID != null) if (query.ImdbID != null)
{
queryCollection.Add("search", query.ImdbID); queryCollection.Add("search", query.ImdbID);
}
else if (!string.IsNullOrWhiteSpace(searchString)) else if (!string.IsNullOrWhiteSpace(searchString))
{
queryCollection.Add("search", searchString); queryCollection.Add("search", searchString);
}
queryCollection.Add("cat", cat); queryCollection.Add("cat", cat);
queryCollection.Add("searchin", "1"); queryCollection.Add("searchin", "1");
@@ -160,15 +153,15 @@ namespace Jackett.Common.Indexers
if (query.ImdbID == null && !query.MatchQueryStringAND(release.Title)) if (query.ImdbID == null && !query.MatchQueryStringAND(release.Title))
continue; continue;
release.Description = row.QuerySelector(".torrenttable:nth-of-type(2) > span > font.small").TextContent; release.Description = row.QuerySelector(".torrenttable:nth-of-type(2) > span > font.small")?.TextContent;
var tooltip = qTitleLink.GetAttribute("title"); var tooltip = qTitleLink.GetAttribute("title");
if (!string.IsNullOrEmpty(tooltip)) if (!string.IsNullOrEmpty(tooltip))
{ {
var ImgRegexp = new Regex("src='(.*?)'"); var imgRegexp = new Regex("src='(.*?)'");
var ImgRegexpMatch = ImgRegexp.Match(tooltip); var imgRegexpMatch = imgRegexp.Match(tooltip);
if (ImgRegexpMatch.Success) if (imgRegexpMatch.Success)
release.BannerUrl = new Uri(ImgRegexpMatch.Groups[1].Value); release.BannerUrl = new Uri(imgRegexpMatch.Groups[1].Value);
} }
release.Guid = new Uri(SiteLink + qTitleLink.GetAttribute("href")); release.Guid = new Uri(SiteLink + qTitleLink.GetAttribute("href"));
@@ -184,15 +177,15 @@ namespace Jackett.Common.Indexers
var sizeStr = row.QuerySelector(".torrenttable:nth-of-type(7)").TextContent.Trim(); var sizeStr = row.QuerySelector(".torrenttable:nth-of-type(7)").TextContent.Trim();
release.Size = ReleaseInfo.GetBytes(sizeStr); release.Size = ReleaseInfo.GetBytes(sizeStr);
var grabs = row.QuerySelector(".torrenttable:nth-of-type(8)").TextContent.Replace("times", "").Trim();
release.Grabs = ParseUtil.CoerceLong(grabs);
release.Seeders = ParseUtil.CoerceInt(row.QuerySelector(".torrenttable:nth-of-type(9)").TextContent.Trim()); 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; release.Peers = ParseUtil.CoerceInt(row.QuerySelector(".torrenttable:nth-of-type(10)").TextContent.Trim()) + release.Seeders;
var catId = row.QuerySelector(".torrenttable:nth-of-type(1) a").GetAttribute("href").Substring(15); var catId = row.QuerySelector(".torrenttable:nth-of-type(1) a").GetAttribute("href").Substring(15);
release.Category = MapTrackerCatToNewznab(catId); release.Category = MapTrackerCatToNewznab(catId);
var grabs = row.QuerySelector(".torrenttable:nth-of-type(8)").FirstChild.FirstChild;
release.Grabs = ParseUtil.CoerceLong(catId);
if (globalFreeLeech || row.QuerySelectorAll("img[alt=\"FreeLeech\"]").Any()) if (globalFreeLeech || row.QuerySelectorAll("img[alt=\"FreeLeech\"]").Any())
release.DownloadVolumeFactor = 0; release.DownloadVolumeFactor = 0;
else else