mirror of
https://github.com/Jackett/Jackett
synced 2024-12-24 00:38:39 +00:00
TorrentDay login fix
This commit is contained in:
parent
e93e95a940
commit
d898725704
1 changed files with 23 additions and 6 deletions
|
@ -36,9 +36,12 @@ namespace Jackett.Indexers
|
|||
public bool IsConfigured { get; private set; }
|
||||
|
||||
const string BaseUrl = "https://torrentday.eu";
|
||||
const string LoginUrl = BaseUrl + "/takelogin.php";
|
||||
const string StartPageUrl = BaseUrl + "/login.php";
|
||||
const string LoginUrl = BaseUrl + "/tak3login.php";
|
||||
const string SearchUrl = BaseUrl + "/browse.php?search={0}&cata=yes&c2=1&c7=1&c14=1&c24=1&c26=1&c31=1&c32=1&c33=1";
|
||||
|
||||
const string chromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
|
||||
|
||||
CookieContainer cookies;
|
||||
HttpClientHandler handler;
|
||||
HttpClient client;
|
||||
|
@ -62,21 +65,35 @@ namespace Jackett.Indexers
|
|||
return Task.FromResult<ConfigurationData>(config);
|
||||
}
|
||||
|
||||
HttpRequestMessage CreateHttpRequest(string uri)
|
||||
{
|
||||
var message = new HttpRequestMessage();
|
||||
message.Method = HttpMethod.Get;
|
||||
message.RequestUri = new Uri(uri);
|
||||
message.Headers.UserAgent.ParseAdd(chromeUserAgent);
|
||||
return message;
|
||||
}
|
||||
|
||||
public async Task ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var startMessage = CreateHttpRequest(StartPageUrl);
|
||||
var results = await (await client.SendAsync(startMessage)).Content.ReadAsStringAsync();
|
||||
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
{ "keeplogged", "1" },
|
||||
{ "login", "Login" }
|
||||
{ "password", config.Password.Value }
|
||||
};
|
||||
|
||||
var content = new FormUrlEncodedContent(pairs);
|
||||
var loginRequest = CreateHttpRequest(LoginUrl);
|
||||
loginRequest.Method = HttpMethod.Post;
|
||||
loginRequest.Content = content;
|
||||
loginRequest.Headers.Referrer = new Uri(StartPageUrl);
|
||||
|
||||
var response = await client.PostAsync(LoginUrl, content);
|
||||
var response = await client.SendAsync(loginRequest);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (!responseContent.Contains("logout.php"))
|
||||
|
|
Loading…
Reference in a new issue