mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Superbits: change to cookie auth
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jackett.Common.Models;
|
using Jackett.Common.Models;
|
||||||
@@ -20,9 +21,9 @@ namespace Jackett.Common.Indexers
|
|||||||
private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } }
|
private string SearchUrl { get { return SiteLink + "api/v1/torrents"; } }
|
||||||
private string LoginUrl { get { return SiteLink + "api/v1/auth"; } }
|
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; }
|
set { base.configData = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,19 +73,26 @@ namespace Jackett.Common.Indexers
|
|||||||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||||
{
|
{
|
||||||
LoadValuesFromJson(configJson);
|
LoadValuesFromJson(configJson);
|
||||||
var queryCollection = new NameValueCollection();
|
|
||||||
|
|
||||||
queryCollection.Add("username", configData.Username.Value);
|
// TODO: implement captcha
|
||||||
queryCollection.Add("password", configData.Password.Value);
|
CookieHeader = configData.Cookie.Value;
|
||||||
|
try
|
||||||
var loginUrl = LoginUrl + "?" + queryCollection.GetQueryString();
|
|
||||||
var loginResult = await RequestStringWithCookies(loginUrl, null, SiteLink);
|
|
||||||
|
|
||||||
await ConfigureIfOK(loginResult.Cookies, loginResult.Content.Contains("\"user\""), () =>
|
|
||||||
{
|
{
|
||||||
throw new ExceptionWithConfigData(loginResult.Content, configData);
|
var results = await PerformQuery(new TorznabQuery());
|
||||||
});
|
if (results.Count() == 0)
|
||||||
return IndexerConfigurationStatus.RequiresTesting;
|
{
|
||||||
|
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<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||||
|
Reference in New Issue
Block a user