1
0
Fork 0
mirror of https://github.com/Jackett/Jackett synced 2025-01-31 20:02:08 +00:00

mejortorrent: fix download urls and grabs. resolves #6449 (#6565)

This commit is contained in:
Diego Heras 2020-01-04 19:42:25 +01:00 committed by garfield69
parent 0046fb2a13
commit ca8fbd081d

View file

@ -18,11 +18,11 @@ namespace Jackett.Common.Indexers
{ {
class MejorTorrent : BaseWebIndexer class MejorTorrent : BaseWebIndexer
{ {
public static Uri WebUri = new Uri("http://www.mejortorrentt.org/"); private static Uri WebUri = new Uri("http://www.mejortorrentt.org/");
public static Uri DownloadUri = new Uri(WebUri, "secciones.php?sec=descargas&ap=contar_varios"); private static Uri DownloadUri = new Uri(WebUri, "secciones.php?sec=descargas&ap=contar_varios");
private static Uri SearchUriBase = new Uri(WebUri, "secciones.php"); private static Uri SearchUriBase = new Uri(WebUri, "secciones.php");
public static Uri NewTorrentsUri = new Uri(WebUri, "secciones.php?sec=ultimos_torrents"); private static Uri NewTorrentsUri = new Uri(WebUri, "secciones.php?sec=ultimos_torrents");
public static Encoding MEEncoding = Encoding.GetEncoding("utf-8"); private static Encoding MEEncoding = Encoding.GetEncoding("utf-8");
public override string[] LegacySiteLinks { get; protected set; } = new string[] { public override string[] LegacySiteLinks { get; protected set; } = new string[] {
"http://www.mejortorrent.org/", "http://www.mejortorrent.org/",
@ -74,7 +74,7 @@ namespace Jackett.Common.Indexers
return await PerformQuery(query, 0); return await PerformQuery(query, 0);
} }
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts) private async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query, int attempts)
{ {
query = query.Clone(); query = query.Clone();
@ -404,9 +404,14 @@ namespace Jackett.Common.Indexers
{ {
public IEnumerable<Uri> Extract(IHtmlDocument html) public IEnumerable<Uri> Extract(IHtmlDocument html)
{ {
return html.QuerySelectorAll("a[href*=\".torrent\"]") List<Uri> uris = new List<Uri>();
.Select(e => e.Attributes["href"].Value) foreach(var elem in html.QuerySelectorAll("a[onclick*=\"/uploads/\"]")) {
.Select(link => new Uri(WebUri, link)); var onclick = elem.Attributes["onclick"].Value;
var table = onclick.Split(new string[] {"table: '"}, StringSplitOptions.None)[1].Split(new string[] {"'"}, StringSplitOptions.None)[0];
var name = onclick.Split(new string[] {"name: '"}, StringSplitOptions.None)[1].Split(new string[] {"'"}, StringSplitOptions.None)[0];
uris.Add(new Uri(WebUri, "/uploads/torrents/" + table + "/" + name));
}
return uris;
} }
} }
@ -458,7 +463,7 @@ namespace Jackett.Common.Indexers
public MTReleaseInfo() public MTReleaseInfo()
{ {
this.Category = new List<int>(); this.Category = new List<int>();
this.Grabs = 5; this.Grabs = null;
this.Files = 1; this.Files = 1;
this.PublishDate = new DateTime(); this.PublishDate = new DateTime();
this.Peers = 1; this.Peers = 1;
@ -682,6 +687,12 @@ namespace Jackett.Common.Indexers
release.TitleOriginal += " (" + year + ")"; release.TitleOriginal += " (" + year + ")";
} catch { } } catch { }
try try
{
var grabsStr = selectors.Where(s => s.TextContent.ToLower().Contains("total descargas"))
.First().NextSibling.TextContent.Trim();
release.Grabs = long.Parse(grabsStr.Replace(".", string.Empty));
} catch { }
try
{ {
var dateStr = selectors.Where(s => s.TextContent.ToLower().Contains("fecha")) var dateStr = selectors.Where(s => s.TextContent.ToLower().Contains("fecha"))
.First().NextSibling.TextContent.Trim(); .First().NextSibling.TextContent.Trim();
@ -759,7 +770,10 @@ namespace Jackett.Common.Indexers
{ {
try try
{ {
return new Uri(WebUri, html.QuerySelector("a[href*=\".torrent\"]").GetAttribute("href")); var onclick = html.QuerySelector("a[onclick*=\"/uploads/\"]").GetAttribute("onclick");
var table = onclick.Split(new string[] {"table: '"}, StringSplitOptions.None)[1].Split(new string[] {"'"}, StringSplitOptions.None)[0];
var name = onclick.Split(new string[] {"name: '"}, StringSplitOptions.None)[1].Split(new string[] {"'"}, StringSplitOptions.None)[0];
return new Uri(WebUri, "/uploads/torrents/" + table + "/" + name);
} }
catch catch
{ {