mirror of
https://github.com/Jackett/Jackett
synced 2024-12-27 18:29:47 +00:00
parent
20637b0e2a
commit
0e2342b8de
1 changed files with 18 additions and 25 deletions
|
@ -22,12 +22,7 @@ namespace Jackett.Common.Indexers
|
|||
{
|
||||
private string LoginPostUrl => SiteLink + "takeloginAjax.php";
|
||||
private string SearchUrl => SiteLink + "browse.php?sort=4&type=desc";
|
||||
|
||||
private new ConfigurationDataBasicLogin configData
|
||||
{
|
||||
get => (ConfigurationDataBasicLogin)base.configData;
|
||||
set => base.configData = value;
|
||||
}
|
||||
private new ConfigurationDataCookie configData => (ConfigurationDataCookie)base.configData;
|
||||
|
||||
public Hebits(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l,
|
||||
IProtectionService ps, ICacheService cs)
|
||||
|
@ -60,7 +55,7 @@ namespace Jackett.Common.Indexers
|
|||
p: ps,
|
||||
cacheService: cs,
|
||||
downloadBase: "https://hebits.net/",
|
||||
configData: new ConfigurationDataBasicLogin())
|
||||
configData: new ConfigurationDataCookie("Easily find the cookie under the 'Cookie' header in the index.php GET request. HeBits Cookie usually look like: hebits=hebits; uid=12345; pass=[...]"))
|
||||
{
|
||||
Encoding = Encoding.GetEncoding("windows-1255");
|
||||
Language = "he-il";
|
||||
|
@ -95,25 +90,23 @@ namespace Jackett.Common.Indexers
|
|||
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
||||
{
|
||||
LoadValuesFromJson(configJson);
|
||||
var pairs = new Dictionary<string, string>
|
||||
{
|
||||
{"username", configData.Username.Value},
|
||||
{"password", configData.Password.Value}
|
||||
};
|
||||
|
||||
// Get inital cookies
|
||||
CookieHeader = string.Empty;
|
||||
var result = await RequestLoginAndFollowRedirect(LoginPostUrl, pairs, CookieHeader, true, null, SiteLink);
|
||||
await ConfigureIfOK(
|
||||
result.Cookies, result.ContentString?.Contains("OK") == true, () =>
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
var dom = parser.ParseDocument(result.ContentString);
|
||||
var errorMessage = dom.TextContent.Trim();
|
||||
errorMessage += " attempts left. Please check your credentials.";
|
||||
throw new ExceptionWithConfigData(errorMessage, configData);
|
||||
});
|
||||
return IndexerConfigurationStatus.RequiresTesting;
|
||||
CookieHeader = configData.Cookie.Value;
|
||||
try
|
||||
{
|
||||
var results = await PerformQuery(new TorznabQuery());
|
||||
if (!results.Any())
|
||||
throw new Exception("Found 0 results in the tracker");
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue