mirror of
https://github.com/Jackett/Jackett
synced 2025-02-24 23:22:46 +00:00
BitHdtv: add recaptcha support
This commit is contained in:
parent
ce8570c656
commit
57b7173237
1 changed files with 43 additions and 6 deletions
|
@ -21,13 +21,14 @@ namespace Jackett.Indexers
|
||||||
{
|
{
|
||||||
public class BitHdtv : BaseIndexer, IIndexer
|
public class BitHdtv : BaseIndexer, IIndexer
|
||||||
{
|
{
|
||||||
private string LoginUrl { get { return SiteLink + "takelogin.php"; } }
|
private string LoginUrl { get { return SiteLink + "login.php"; } }
|
||||||
|
private string TakeLoginUrl { get { return SiteLink + "takelogin.php"; } }
|
||||||
private string SearchUrl { get { return SiteLink + "torrents.php?"; } }
|
private string SearchUrl { get { return SiteLink + "torrents.php?"; } }
|
||||||
private string DownloadUrl { get { return SiteLink + "download.php?id={0}"; } }
|
private string DownloadUrl { get { return SiteLink + "download.php?id={0}"; } }
|
||||||
|
|
||||||
new ConfigurationDataBasicLogin configData
|
new ConfigurationDataRecaptchaLogin configData
|
||||||
{
|
{
|
||||||
get { return (ConfigurationDataBasicLogin)base.configData; }
|
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
|
||||||
set { base.configData = value; }
|
set { base.configData = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ namespace Jackett.Indexers
|
||||||
client: w,
|
client: w,
|
||||||
logger: l,
|
logger: l,
|
||||||
p: ps,
|
p: ps,
|
||||||
configData: new ConfigurationDataBasicLogin())
|
configData: new ConfigurationDataRecaptchaLogin())
|
||||||
{
|
{
|
||||||
Encoding = Encoding.GetEncoding("iso-8859-1");
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
||||||
Language = "en-us";
|
Language = "en-us";
|
||||||
|
@ -58,16 +59,52 @@ namespace Jackett.Indexers
|
||||||
AddCategoryMapping(11, TorznabCatType.XXX); // XXX
|
AddCategoryMapping(11, TorznabCatType.XXX); // XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<ConfigurationData> GetConfigurationForSetup()
|
||||||
|
{
|
||||||
|
var loginPage = await RequestStringWithCookies(LoginUrl, configData.CookieHeader.Value);
|
||||||
|
CQ cq = loginPage.Content;
|
||||||
|
string recaptchaSiteKey = cq.Find(".g-recaptcha").Attr("data-sitekey");
|
||||||
|
var result = this.configData;
|
||||||
|
result.CookieHeader.Value = loginPage.Cookies;
|
||||||
|
result.Captcha.SiteKey = recaptchaSiteKey;
|
||||||
|
result.Captcha.Version = "2";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
|
|
||||||
var pairs = new Dictionary<string, string> {
|
var pairs = new Dictionary<string, string> {
|
||||||
{ "username", configData.Username.Value },
|
{ "username", configData.Username.Value },
|
||||||
{ "password", configData.Password.Value }
|
{ "password", configData.Password.Value },
|
||||||
|
{ "g-recaptcha-response", configData.Captcha.Value },
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, SiteLink);
|
if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie))
|
||||||
|
{
|
||||||
|
// Cookie was manually supplied
|
||||||
|
CookieHeader = configData.Captcha.Cookie;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
|
if (!results.Any())
|
||||||
|
{
|
||||||
|
throw new Exception("Your cookie did not work");
|
||||||
|
}
|
||||||
|
|
||||||
|
IsConfigured = true;
|
||||||
|
SaveConfig();
|
||||||
|
return IndexerConfigurationStatus.Completed;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
IsConfigured = false;
|
||||||
|
throw new Exception("Your cookie did not work: " + e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await RequestLoginAndFollowRedirect(TakeLoginUrl, pairs, null, true, null, SiteLink);
|
||||||
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("logout.php"), () =>
|
await ConfigureIfOK(response.Cookies, response.Content != null && response.Content.Contains("logout.php"), () =>
|
||||||
{
|
{
|
||||||
CQ dom = response.Content;
|
CQ dom = response.Content;
|
||||||
|
|
Loading…
Reference in a new issue