BeyondHD: Use Login Link (#772)

This commit is contained in:
kaso17
2016-11-30 18:33:09 +01:00
committed by GitHub
parent ac4787e292
commit dd4eaed4fa
3 changed files with 38 additions and 51 deletions

View File

@@ -18,12 +18,10 @@ namespace Jackett.Indexers
public class BeyondHD : BaseIndexer, IIndexer
{
private string SearchUrl { get { return SiteLink + "browse.php?searchin=title&incldead=0&"; } }
private string LoginUrl { get { return SiteLink + "login.php?returnto=%2F"; } }
private string AjaxLoginUrl { get { return SiteLink + "ajax/takelogin.php"; } }
new ConfigurationDataRecaptchaLogin configData
new ConfigurationDataLoginLink configData
{
get { return (ConfigurationDataRecaptchaLogin)base.configData; }
get { return (ConfigurationDataLoginLink)base.configData; }
set { base.configData = value; }
}
@@ -36,8 +34,10 @@ namespace Jackett.Indexers
client: w,
logger: l,
p: ps,
configData: new ConfigurationDataRecaptchaLogin())
configData: new ConfigurationDataLoginLink())
{
configData.DisplayText.Value = "Go to the general tab of your BeyondHD user profile and create/copy the Login Link.";
AddCategoryMapping(37, TorznabCatType.MoviesBluRay); // Movie / Blu-ray
AddMultiCategoryMapping(TorznabCatType.Movies3D,
71, // Movie / 3D
@@ -53,7 +53,10 @@ namespace Jackett.Indexers
75, // Internal / FraMeSToR 720p
49, // Internal / FraMeSToR REMUX
61, // Internal / HDX REMUX
86 // Internal / SC4R
86, // Internal / SC4R
95, // Nightripper 1080p
96, // Nightripper 720p
98 // Nightripper MicroHD
);
AddMultiCategoryMapping(TorznabCatType.TVHD,
@@ -62,7 +65,8 @@ namespace Jackett.Indexers
48, // TV Show / HDTV
89, // TV Show / Packs
46, // TV Show / Remux
45 // TV Show / WEB-DL
45, // TV Show / WEB-DL
97 // Nightripper TV Show Encodes
);
AddCategoryMapping(36, TorznabCatType.AudioLossless); // Music / Lossless
@@ -76,53 +80,12 @@ namespace Jackett.Indexers
}
public override async Task<ConfigurationData> GetConfigurationForSetup()
{
var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty);
string recaptchaSiteKey = new Regex(@"loginwidget', \{[\s]{4,30}'sitekey' : '([0-9A-Za-z-]{5,60})',[\s]{4,30}'theme'").Match(loginPage.Content).Groups[1].ToString().Trim();
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)
{
configData.LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value },
{ "g-recaptcha-response", configData.Captcha.Value }
};
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");
}
SaveConfig();
IsConfigured = true;
return IndexerConfigurationStatus.Completed;
}
catch (Exception e)
{
IsConfigured = false;
throw new Exception("Your cookie did not work: " + e.Message);
}
}
var result = await RequestLoginAndFollowRedirect(AjaxLoginUrl, pairs, configData.CookieHeader.Value, true, SiteLink, LoginUrl);
JToken token = JObject.Parse(result.Content);
bool success = token.Value<bool?>("success") ?? false;
await ConfigureIfOK(result.Cookies, success, () =>
var result = await RequestStringWithCookies(configData.LoginLink.Value);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("Welcome Back"), () =>
{
var errorMessage = result.Content;
throw new ExceptionWithConfigData(errorMessage, configData);

View File

@@ -228,6 +228,7 @@
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithFilterAndPasskey.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithFilter.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataAPIKey.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataLoginLink.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithRSSAndDisplay.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithAlternateLink.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataRecaptchaLoginWithAlternateLink.cs" />

View File

@@ -0,0 +1,23 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Models.IndexerConfig
{
public class ConfigurationDataLoginLink : ConfigurationData
{
public StringItem LoginLink { get; private set; }
public HiddenItem RSSKey { get; private set; }
public DisplayItem DisplayText { get; private set; }
public ConfigurationDataLoginLink()
{
LoginLink = new StringItem { Name = "Login Link" };
RSSKey = new HiddenItem { Name = "RSSKey" };
DisplayText = new DisplayItem(""){ Name = "" };
}
}
}