mirror of https://github.com/Jackett/Jackett
Convert SpeedCD to AngleSharp (#7389)
This commit is contained in:
parent
d22ef13fb2
commit
08a68e0116
|
@ -2,10 +2,10 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CsQuery;
|
||||
using AngleSharp.Dom;
|
||||
using AngleSharp.Html.Parser;
|
||||
using Jackett.Common.Models;
|
||||
using Jackett.Common.Models.IndexerConfig;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
|
@ -98,7 +98,8 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("/browse.php"), () =>
|
||||
{
|
||||
CQ dom = result.Content;
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(result.Content);
|
||||
var errorMessage = dom.Text();
|
||||
if (errorMessage.Contains("Wrong Captcha!"))
|
||||
errorMessage = "Captcha requiered due to a failed login attempt. Login via a browser to whitelist your IP and then reconfigure jackett.";
|
||||
|
@ -144,27 +145,27 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
try
|
||||
{
|
||||
CQ dom = response.Content;
|
||||
var rows = dom["div[id='torrentTable'] > div[class^='box torrentBox'] > div[class='boxContent'] > table > tbody > tr"];
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(response.Content);
|
||||
var rows = dom.QuerySelectorAll("div[id='torrentTable'] > div[class^='box torrentBox'] > div[class='boxContent'] > table > tbody > tr");
|
||||
|
||||
foreach (var row in rows)
|
||||
{
|
||||
CQ torrentData = row.OuterHTML;
|
||||
var cells = row.Cq().Find("td");
|
||||
var cells = row.QuerySelectorAll("td");
|
||||
|
||||
var title = torrentData.Find("td[class='lft'] > div > a").First().Text().Trim();
|
||||
var link = new Uri(SiteLink + torrentData.Find("img[title='Download']").First().Parent().Attr("href").Trim());
|
||||
var title = row.QuerySelector("td[class='lft'] > div > a").TextContent.Trim();
|
||||
var link = new Uri(SiteLink + row.QuerySelector("img[title='Download']").ParentElement.GetAttribute("href").Trim());
|
||||
var guid = link;
|
||||
var comments = new Uri(SiteLink + torrentData.Find("td[class='lft'] > div > a").First().Attr("href").Trim().Remove(0, 1));
|
||||
var size = ReleaseInfo.GetBytes(cells.Elements.ElementAt(4).Cq().Text());
|
||||
var grabs = ParseUtil.CoerceInt(cells.Elements.ElementAt(5).Cq().Text());
|
||||
var seeders = ParseUtil.CoerceInt(cells.Elements.ElementAt(6).Cq().Text());
|
||||
var leechers = ParseUtil.CoerceInt(cells.Elements.ElementAt(7).Cq().Text());
|
||||
var comments = new Uri(SiteLink + row.QuerySelector("td[class='lft'] > div > a").GetAttribute("href").Trim().Remove(0, 1));
|
||||
var size = ReleaseInfo.GetBytes(cells[4].TextContent);
|
||||
var grabs = ParseUtil.CoerceInt(cells[5].TextContent);
|
||||
var seeders = ParseUtil.CoerceInt(cells[6].TextContent);
|
||||
var leechers = ParseUtil.CoerceInt(cells[7].TextContent);
|
||||
|
||||
var pubDateStr = torrentData.Find("span[class^='elapsedDate']").First().Attr("title").Trim().Replace(" at", "");
|
||||
var pubDateStr = row.QuerySelector("span[class^='elapsedDate']").GetAttribute("title").Trim().Replace(" at", "");
|
||||
var publishDate = DateTime.ParseExact(pubDateStr, "dddd, MMMM d, yyyy h:mmtt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime();
|
||||
|
||||
var cat = torrentData.Find("img[class^='Tcat']").First().Parent().Attr("href").Trim().Remove(0, 5);
|
||||
var cat = row.QuerySelector("img[class^='Tcat']").ParentElement.GetAttribute("href").Trim().Remove(0, 5);
|
||||
long.TryParse(cat, out var category);
|
||||
|
||||
// This fixes the mixed initializer issue, so it's just inconsistent in the code base.
|
||||
|
@ -184,11 +185,7 @@ namespace Jackett.Common.Indexers
|
|||
release.Category = MapTrackerCatToNewznab(category.ToString());
|
||||
release.Comments = comments;
|
||||
|
||||
if (torrentData.Find("span:contains(\"[Freeleech]\")").Any())
|
||||
release.DownloadVolumeFactor = 0;
|
||||
else
|
||||
release.DownloadVolumeFactor = 1;
|
||||
|
||||
release.DownloadVolumeFactor = row.QuerySelector("span:contains(\"[Freeleech]\")") != null ? 0 : 1;
|
||||
release.UploadVolumeFactor = 1;
|
||||
|
||||
releases.Add(release);
|
||||
|
|
Loading…
Reference in New Issue