From 8b34e80d5b211c4b958ef0f2d6d05b540699be49 Mon Sep 17 00:00:00 2001 From: ERR1R Date: Fri, 3 Jan 2020 18:49:08 +0100 Subject: [PATCH] digitalcore: Cookie workaround because captcha (#6779) resolves #6770 dc added a captcha system.. cookie workaround! --- src/Jackett.Common/Indexers/digitalcore.cs | 42 ++++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/Jackett.Common/Indexers/digitalcore.cs b/src/Jackett.Common/Indexers/digitalcore.cs index 187271bc3..897a0bca1 100644 --- a/src/Jackett.Common/Indexers/digitalcore.cs +++ b/src/Jackett.Common/Indexers/digitalcore.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; +using System.Linq; using System.Text; using System.Threading.Tasks; using Jackett.Common.Models; @@ -20,12 +21,13 @@ namespace Jackett.Common.Indexers private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } } private string LoginUrl { get { return SiteLink + "api/v1/auth"; } } - private new ConfigurationDataBasicLogin configData + private new ConfigurationDataCookie configData { - get { return (ConfigurationDataBasicLogin)base.configData; } + get { return (ConfigurationDataCookie)base.configData; } set { base.configData = value; } } + public Digitalcore(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "DigitalCore", description: "DigitalCore is a Private Torrent Tracker for MOVIES / TV / GENERAL", @@ -35,7 +37,7 @@ namespace Jackett.Common.Indexers client: w, logger: l, p: ps, - configData: new ConfigurationDataBasicLogin()) + configData: new ConfigurationDataCookie()) { Encoding = Encoding.UTF8; Language = "en-us"; @@ -83,19 +85,26 @@ namespace Jackett.Common.Indexers public override async Task ApplyConfiguration(JToken configJson) { LoadValuesFromJson(configJson); - var queryCollection = new NameValueCollection(); - queryCollection.Add("username", configData.Username.Value); - queryCollection.Add("password", configData.Password.Value); - - var loginUrl = LoginUrl + "?" + queryCollection.GetQueryString(); - var loginResult = await RequestStringWithCookies(loginUrl, null, SiteLink); - - await ConfigureIfOK(loginResult.Cookies, loginResult.Content.Contains("\"user\""), () => + // TODO: implement captcha + CookieHeader = configData.Cookie.Value; + try { - throw new ExceptionWithConfigData(loginResult.Content, configData); - }); - return IndexerConfigurationStatus.RequiresTesting; + var results = await PerformQuery(new TorznabQuery()); + if (results.Count() == 0) + { + 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); + } } protected override async Task> PerformQuery(TorznabQuery query) @@ -162,6 +171,7 @@ namespace Jackett.Common.Indexers release.BannerUrl = (row.firstpic); } + if (row.imdbid2 != null && row.imdbid2.ToString().StartsWith("tt")) { release.Imdb = ParseUtil.CoerceLong(row.imdbid2.ToString().Substring(2)); @@ -171,6 +181,8 @@ namespace Jackett.Common.Indexers descriptions.Add("Tagline: " + row.tagline); descriptions.Add("Cast: " + row.cast); descriptions.Add("Rating: " + row.rating); + //descriptions.Add("Plot: " + row.plot); + release.BannerUrl = new Uri(SiteLink + "img/imdb/" + row.imdbid2 + ".jpg"); } @@ -193,7 +205,7 @@ namespace Jackett.Common.Indexers release.Description = string.Join("
\n", descriptions); - releases.Add(release); + releases.Add(release); } }