Redacted: fix download without FL tokens

This commit is contained in:
kaso17 2018-06-15 17:14:56 +02:00
parent 3538fdfaf7
commit c109133fcc
1 changed files with 23 additions and 0 deletions

View File

@ -283,5 +283,28 @@ namespace Jackett.Common.Indexers.Abstract
release.UploadVolumeFactor = 0; release.UploadVolumeFactor = 0;
} }
} }
public override async Task<byte[]> Download(Uri link)
{
var content = await base.Download(link);
// Check if we're out of FL tokens
// most gazelle trackers will simply return the torrent anyway but e.g. redacted will return an error
var requestLink = link.ToString();
if (content.Length >= 1
&& content[0] != 'd' // simple test for torrent vs HTML content
&& requestLink.Contains("usetoken=1"))
{
var html = Encoding.UTF8.GetString(content);
if (html.Contains("You do not have any freeleech tokens left."))
{
// download again with usetoken=0
var requestLinkNew = requestLink.Replace("usetoken=1", "usetoken=0");
content = await base.Download(new Uri(requestLinkNew));
}
}
return content;
}
} }
} }