From dd4eaed4faadd69fb715a81bc19b9986c363314c Mon Sep 17 00:00:00 2001 From: kaso17 Date: Wed, 30 Nov 2016 18:33:09 +0100 Subject: [PATCH] BeyondHD: Use Login Link (#772) --- src/Jackett/Indexers/BeyondHD.cs | 65 ++++--------------- src/Jackett/Jackett.csproj | 1 + .../ConfigurationDataLoginLink.cs | 23 +++++++ 3 files changed, 38 insertions(+), 51 deletions(-) create mode 100644 src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs diff --git a/src/Jackett/Indexers/BeyondHD.cs b/src/Jackett/Indexers/BeyondHD.cs index e88c98ba6..41bd58eac 100644 --- a/src/Jackett/Indexers/BeyondHD.cs +++ b/src/Jackett/Indexers/BeyondHD.cs @@ -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 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 ApplyConfiguration(JToken configJson) { configData.LoadValuesFromJson(configJson); - var pairs = new Dictionary { - { "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("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); diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index f894eec29..664f1607b 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -228,6 +228,7 @@ + diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs b/src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs new file mode 100644 index 000000000..c3f2434dc --- /dev/null +++ b/src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs @@ -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 = "" }; + } + } +}