mirror of https://github.com/Jackett/Jackett
IPTorrents fixes for Cloudflare (#12939)
This commit is contained in:
parent
49a0c2d7e0
commit
268a334643
|
@ -49,7 +49,7 @@ namespace Jackett.Common.Indexers
|
|||
"https://iptorrents.eu/"
|
||||
};
|
||||
|
||||
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
|
||||
private new ConfigurationDataCookieUA configData => (ConfigurationDataCookieUA)base.configData;
|
||||
|
||||
public IPTorrents(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps,
|
||||
ICacheService cs)
|
||||
|
@ -81,7 +81,7 @@ namespace Jackett.Common.Indexers
|
|||
logger: l,
|
||||
p: ps,
|
||||
cacheService: cs,
|
||||
configData: new ConfigurationDataCookie("For best results, change the 'Torrents per page' option to 100 and check the 'Torrents - Show files count' option in the website Settings."))
|
||||
configData: new ConfigurationDataCookieUA("For best results, change the 'Torrents per page' option to 100 and check the 'Torrents - Show files count' option in the website Settings."))
|
||||
{
|
||||
Encoding = Encoding.UTF8;
|
||||
Language = "en-US";
|
||||
|
@ -177,6 +177,7 @@ namespace Jackett.Common.Indexers
|
|||
LoadValuesFromJson(configJson);
|
||||
|
||||
CookieHeader = configData.Cookie.Value;
|
||||
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
|
@ -190,7 +191,7 @@ namespace Jackett.Common.Indexers
|
|||
catch (Exception e)
|
||||
{
|
||||
IsConfigured = false;
|
||||
throw new Exception("Your cookie did not work: " + e.Message);
|
||||
throw new Exception("Your cookie did not work, make sure the user agent matches your computer: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,6 +201,15 @@ namespace Jackett.Common.Indexers
|
|||
|
||||
var qc = new NameValueCollection();
|
||||
|
||||
|
||||
Dictionary<string, string> headers = null;
|
||||
|
||||
if (!string.IsNullOrEmpty(configData.UserAgent.Value))
|
||||
{
|
||||
headers = new Dictionary<string, string>();
|
||||
headers.Add("User-Agent", configData.UserAgent.Value);
|
||||
}
|
||||
|
||||
if (query.IsImdbQuery)
|
||||
qc.Add("q", query.ImdbID);
|
||||
else if (!string.IsNullOrWhiteSpace(query.GetQueryString()))
|
||||
|
@ -214,7 +224,7 @@ namespace Jackett.Common.Indexers
|
|||
qc.Add("o", ((SingleSelectConfigurationItem)configData.GetDynamic("sort")).Value);
|
||||
|
||||
var searchUrl = SearchUrl + "?" + qc.GetQueryString();
|
||||
var response = await RequestWithCookiesAndRetryAsync(searchUrl, referer: SearchUrl);
|
||||
var response = await RequestWithCookiesAndRetryAsync(searchUrl, referer: SearchUrl, headers: headers);
|
||||
var results = response.ContentString;
|
||||
|
||||
if (results == null || !results.Contains("/lout.php"))
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
namespace Jackett.Common.Models.IndexerConfig
|
||||
{
|
||||
public class ConfigurationDataCookieUA : ConfigurationData
|
||||
{
|
||||
public StringConfigurationItem Cookie { get; private set; }
|
||||
public DisplayInfoConfigurationItem CookieInstructions { get; private set; }
|
||||
public StringConfigurationItem UserAgent { get; private set; }
|
||||
public DisplayInfoConfigurationItem UserAgentInstructions { get; private set; }
|
||||
public DisplayInfoConfigurationItem Instructions { get; private set; }
|
||||
|
||||
public ConfigurationDataCookieUA(string instructionMessageOptional = null)
|
||||
{
|
||||
Cookie = new StringConfigurationItem("Cookie");
|
||||
CookieInstructions = new DisplayInfoConfigurationItem("Cookie Instructions",
|
||||
"Please enter the cookie for the site manually. <a href=\"https://github.com/Jackett/Jackett/wiki/Finding-cookies\" target=\"_blank\">See here</a> on how get the cookies." +
|
||||
"<br>Example cookie header (usually longer than this):<br><code>PHPSESSID=8rk27odm; ipsconnect_63ad9c=1; more_stuff=etc;</code>");
|
||||
UserAgent = new StringConfigurationItem("User-Agent");
|
||||
UserAgentInstructions = new DisplayInfoConfigurationItem("User Agent Instructions",
|
||||
"<ol><li>From the same place you fetched the cookie,<li>Find <b>'user-agent:'</b> in the <b>Request Headers</b> section<li><b>Select</b>" +
|
||||
"and <b>Copy</b> the whole user-agent string <i>(everything after 'user-agent: ')</i> and <b>Paste</b> here.</ol>");
|
||||
Instructions = new DisplayInfoConfigurationItem("", instructionMessageOptional);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue