From ac07cc34cd9d9a06e77f9ba718bbb0302cfceb9d Mon Sep 17 00:00:00 2001 From: flightlevel Date: Sat, 28 May 2016 19:40:39 +1000 Subject: [PATCH] SpeedCD: Fix Login (#354) SpeedCD: Fix Login --- src/Jackett/Indexers/SpeedCD.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Jackett/Indexers/SpeedCD.cs b/src/Jackett/Indexers/SpeedCD.cs index c62ac2c70..570b72708 100644 --- a/src/Jackett/Indexers/SpeedCD.cs +++ b/src/Jackett/Indexers/SpeedCD.cs @@ -17,7 +17,7 @@ namespace Jackett.Indexers { public class SpeedCD : BaseIndexer, IIndexer { - private string LoginUrl { get { return SiteLink + "take.login.php"; } } + private string LoginUrl { get { return SiteLink + "takelogin.php"; } } private string SearchUrl { get { return SiteLink + "browse.php"; } } new ConfigurationDataBasicLogin configData @@ -70,24 +70,39 @@ namespace Jackett.Indexers public async Task ApplyConfiguration(JToken configJson) { configData.LoadValuesFromJson(configJson); + + await DoLogin(); + + return IndexerConfigurationStatus.RequiresTesting; + } + + private async Task DoLogin() + { var pairs = new Dictionary { { "username", configData.Username.Value }, { "password", configData.Password.Value }, }; var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, SiteLink); + await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () => { CQ dom = result.Content; var errorMessage = dom["h5"].First().Text().Trim(); throw new ExceptionWithConfigData(errorMessage, configData); }); - - return IndexerConfigurationStatus.RequiresTesting; } public async Task> PerformQuery(TorznabQuery query) { + var loggedInCheck = await RequestStringWithCookies(SearchUrl); + if (!loggedInCheck.Content.Contains("/logout.php")) + { + //Cookie appears to expire after a period of time or logging in to the site via browser + await DoLogin(); + } + + var releases = new List(); NameValueCollection qParams = new NameValueCollection();