mirror of
https://github.com/Jackett/Jackett
synced 2025-01-01 04:38:20 +00:00
parent
d8361f3486
commit
b70f38b8ff
2 changed files with 55 additions and 29 deletions
|
@ -23,9 +23,9 @@ namespace Jackett.Common.Indexers
|
|||
private string DetailURL { get { return "https://passthepopcorn.me/torrents.php?torrentid="; } }
|
||||
private string AuthKey { get; set; }
|
||||
|
||||
private new ConfigurationDataBasicLoginWithFilterAndPasskey configData
|
||||
private new ConfigurationDataAPILoginWithUserAndPasskeyAndFilter configData
|
||||
{
|
||||
get { return (ConfigurationDataBasicLoginWithFilterAndPasskey)base.configData; }
|
||||
get { return (ConfigurationDataAPILoginWithUserAndPasskeyAndFilter)base.configData; }
|
||||
set { base.configData = value; }
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace Jackett.Common.Indexers
|
|||
client: c,
|
||||
logger: l,
|
||||
p: ps,
|
||||
configData: new ConfigurationDataBasicLoginWithFilterAndPasskey(@"Enter filter options below to restrict search results.
|
||||
configData: new ConfigurationDataAPILoginWithUserAndPasskeyAndFilter(@"Enter filter options below to restrict search results.
|
||||
Separate options with a space if using more than one option.<br>Filter options available:
|
||||
<br><code>GoldenPopcorn</code><br><code>Scene</code><br><code>Checked</code><br><code>Free</code>"))
|
||||
{
|
||||
|
@ -69,29 +69,21 @@ namespace Jackett.Common.Indexers
|
|||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
|
||||
await DoLogin();
|
||||
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
}
|
||||
|
||||
private async Task DoLogin()
|
||||
{
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", configData.Username.Value },
|
||||
{ "password", configData.Password.Value },
|
||||
{ "passkey", configData.Passkey.Value },
|
||||
{ "keeplogged", "1" },
|
||||
{ "login", "Log In!" }
|
||||
};
|
||||
|
||||
var response = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, indexUrl, SiteLink);
|
||||
JObject js_response = JObject.Parse(response.Content);
|
||||
await ConfigureIfOK(response.Cookies, response.Content != null && (string)js_response["Result"] != "Error", () =>
|
||||
IsConfigured = false;
|
||||
try
|
||||
{
|
||||
// Landing page wil have "Result":"Error" if log in fails
|
||||
string errorMessage = (string)js_response["Message"];
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (results.Count() == 0)
|
||||
throw new Exception("Testing returned no results!");
|
||||
IsConfigured = true;
|
||||
SaveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ExceptionWithConfigData(e.Message, configData);
|
||||
}
|
||||
|
||||
return IndexerConfigurationStatus.Completed;
|
||||
}
|
||||
|
||||
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
||||
|
@ -124,12 +116,16 @@ namespace Jackett.Common.Indexers
|
|||
movieListSearchUrl += "?" + queryCollection.GetQueryString();
|
||||
}
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(movieListSearchUrl);
|
||||
var authHeaders = new Dictionary<string, string>()
|
||||
{
|
||||
{ "ApiUser", configData.User.Value },
|
||||
{ "ApiKey", configData.Key.Value }
|
||||
};
|
||||
|
||||
var results = await RequestStringWithCookiesAndRetry(movieListSearchUrl, null, null, authHeaders);
|
||||
if (results.IsRedirect) // untested
|
||||
{
|
||||
// re-login
|
||||
await DoLogin();
|
||||
results = await RequestStringWithCookiesAndRetry(movieListSearchUrl);
|
||||
results = await RequestStringWithCookiesAndRetry(movieListSearchUrl, null, null, authHeaders);
|
||||
}
|
||||
try
|
||||
{
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
namespace Jackett.Common.Models.IndexerConfig
|
||||
{
|
||||
public class ConfigurationDataAPILoginWithUserAndPasskeyAndFilter : ConfigurationData
|
||||
{
|
||||
public StringItem Passkey { get; private set; }
|
||||
public DisplayItem KeyHint { get; private set; }
|
||||
public StringItem User { get; private set; }
|
||||
public StringItem Key { get; private set; }
|
||||
public DisplayItem FilterExample { get; private set; }
|
||||
public StringItem FilterString { get; private set; }
|
||||
|
||||
public ConfigurationDataAPILoginWithUserAndPasskeyAndFilter(string FilterInstructions)
|
||||
{
|
||||
Passkey = new StringItem { Name = "Passkey", Value = string.Empty };
|
||||
|
||||
KeyHint = new DisplayItem("<ul><li>Visit the security tab on your user settings page to access your ApiUser and ApiKey <li>If you haven't yet generated a key, you may have to first generate one using the checkbox below your keys</ul>")
|
||||
{
|
||||
Name = "API Authentication"
|
||||
};
|
||||
User = new StringItem { Name = "ApiUser", Value = string.Empty };
|
||||
Key = new StringItem { Name = "ApiKey", Value = string.Empty };
|
||||
|
||||
FilterExample = new DisplayItem(FilterInstructions)
|
||||
{
|
||||
Name = ""
|
||||
};
|
||||
FilterString = new StringItem { Name = "Filters (optional)" };
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue