Newpct: fix broken download (#12984)

This commit is contained in:
snamds 2022-02-22 20:22:26 +01:00 committed by GitHub
parent aecd081b71
commit 0bec5204d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -175,13 +175,14 @@ namespace Jackett.Common.Indexers
{ {
Uri uriLink = null; Uri uriLink = null;
var downloadLink = linkParam.AbsoluteUri.Replace("/descargar/", "/descargar/torrent/"); var downloadLink = linkParam.AbsoluteUri.Replace("/descargar/", "/descargar/torrent/");
var downloadHost = "https://atomtt.com/";
var result = await RequestWithCookiesAndRetryAsync(downloadLink, referer: linkParam.AbsoluteUri); var result = await RequestWithCookiesAndRetryAsync(downloadLink, referer: linkParam.AbsoluteUri);
var downloadRegex = new Regex("/t_download/([0-9]+)/"); var downloadRegex = new Regex("/t_download/([0-9]+)/");
var match = downloadRegex.Match(result.ContentString); var match = downloadRegex.Match(result.ContentString);
if (match.Success) if (match.Success)
{ {
const string downloadUrl = "https://atomtt.com/to.php"; string downloadUrl = downloadHost + "to.php";
var headers = new Dictionary<string, string> var headers = new Dictionary<string, string>
{ {
{"X-Requested-With", "XMLHttpRequest"}, {"X-Requested-With", "XMLHttpRequest"},
@ -191,13 +192,13 @@ namespace Jackett.Common.Indexers
result = await RequestWithCookiesAsync(downloadUrl, method: RequestType.POST, rawbody: body, result = await RequestWithCookiesAsync(downloadUrl, method: RequestType.POST, rawbody: body,
headers: headers, referer: downloadLink); headers: headers, referer: downloadLink);
if (result.Status == HttpStatusCode.OK) if (result.Status == HttpStatusCode.OK)
uriLink = new Uri(SiteLink + "t_download/" + result.ContentString + ".torrent"); uriLink = new Uri(new Uri(SiteLink), result.ContentString);
} }
if (uriLink == null) if (uriLink == null)
throw new Exception("Download link not found!"); throw new Exception("Download link not found!");
return await base.Download(uriLink); return await base.Download(uriLink, RequestType.GET, downloadHost);
} }
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query) protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)