This commit is contained in:
Dmitry Chepurovskiy 2022-06-05 00:04:05 +03:00
parent 281547d39d
commit bef802eda0
No known key found for this signature in database
GPG key ID: 5B3A5FDCBFF9B3A4
3 changed files with 43 additions and 19 deletions

View file

@ -56,10 +56,30 @@ public override IParseIndexerResponse GetParser()
return new LostfilmParser(Settings, Capabilities.Categories) { HttpClient = _httpClient, Logger = _logger };
}
// protected override async Task DoLogin()
// {
// UpdateCookies(null, null);
protected override async Task DoLogin()
{
UpdateCookies(null, null);
var loginPage = await ExecuteAuth(new HttpRequest(Settings.BaseUrl + "login"));
// UpdateCookies(loginPage.Cookies);
var parser = new HtmlParser();
var document = parser.ParseDocument(loginPage.Content);
var qCaptchaImg = document.QuerySelector("img#captcha_pictcha");
if (qCaptchaImg != null)
{
var captchaUrl = Settings.BaseUrl + qCaptchaImg.GetAttribute("src");
var captchaImage = await ExecuteAuth(new HttpRequest(captchaUrl));
Settings.ExtraFieldData["CAPTCHA"] = captchaImage.Content;
}
// else
// {
// configData.CaptchaImage.Value = new byte[0];
// }
// configData.CaptchaCookie.Value = loginPage.Cookies;
}
// UpdateCookies(null, null);
// var requestBuilder = new HttpRequestBuilder(Settings.BaseUrl + "index.php")
// {
// LogResponseContent = true,

View file

@ -1,26 +1,29 @@
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Settings
{
public class UserPassTorrentBaseSettings : ITorrentIndexerSettings
public class UserPassCaptchaTorrentBaseSettings : ITorrentIndexerSettings
{
public class UserPassBaseSettingsValidator : AbstractValidator<UserPassTorrentBaseSettings>
public class UserPassCaptchaBaseSettingsValidator : AbstractValidator<UserPassCaptchaTorrentBaseSettings>
{
public UserPassBaseSettingsValidator()
public UserPassCaptchaBaseSettingsValidator()
{
RuleFor(c => c.Username).NotEmpty();
RuleFor(c => c.Password).NotEmpty();
}
}
private static readonly UserPassBaseSettingsValidator Validator = new UserPassBaseSettingsValidator();
private static readonly UserPassCaptchaBaseSettingsValidator Validator = new UserPassCaptchaBaseSettingsValidator();
public UserPassTorrentBaseSettings()
public UserPassCaptchaTorrentBaseSettings()
{
Username = "";
Password = "";
Captcha = "";
ExtraFieldData = new Dictionary<string, object>();
}
[FieldDefinition(1, Label = "Base Url", HelpText = "Select which baseurl Prowlarr will use for requests to the site", Type = FieldType.Select, SelectOptionsProviderAction = "getUrls")]
@ -32,12 +35,17 @@ public UserPassTorrentBaseSettings()
[FieldDefinition(3, Label = "Password", HelpText = "Site Password", Privacy = PrivacyLevel.Password, Type = FieldType.Password)]
public string Password { get; set; }
[FieldDefinition(4)]
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
[FieldDefinition(4, Label = "Captcha", HelpText = "Site Captcha", Privacy = PrivacyLevel.Normal, Type = FieldType.Captcha)]
public string Captcha { get; set; }
[FieldDefinition(5)]
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
[FieldDefinition(6)]
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
public Dictionary<string, object> ExtraFieldData { get; set; }
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));

View file

@ -4,9 +4,9 @@
namespace NzbDrone.Core.Indexers.Settings
{
public class UserPassCaptchaTorrentBaseSettings : ITorrentIndexerSettings
public class UserPassTorrentBaseSettings : ITorrentIndexerSettings
{
public class UserPassBaseSettingsValidator : AbstractValidator<UserPassCaptchaTorrentBaseSettings>
public class UserPassBaseSettingsValidator : AbstractValidator<UserPassTorrentBaseSettings>
{
public UserPassBaseSettingsValidator()
{
@ -17,11 +17,10 @@ public UserPassBaseSettingsValidator()
private static readonly UserPassBaseSettingsValidator Validator = new UserPassBaseSettingsValidator();
public UserPassCaptchaTorrentBaseSettings()
public UserPassTorrentBaseSettings()
{
Username = "";
Password = "";
Captcha = "";
}
[FieldDefinition(1, Label = "Base Url", HelpText = "Select which baseurl Prowlarr will use for requests to the site", Type = FieldType.Select, SelectOptionsProviderAction = "getUrls")]
@ -33,13 +32,10 @@ public UserPassCaptchaTorrentBaseSettings()
[FieldDefinition(3, Label = "Password", HelpText = "Site Password", Privacy = PrivacyLevel.Password, Type = FieldType.Password)]
public string Password { get; set; }
[FieldDefinition(4, Label = "Captcha", HelpText = "Site Captcha", Privacy = PrivacyLevel.Normal, Type = FieldType.Captcha)]
public string Captcha { get; set; }
[FieldDefinition(5)]
[FieldDefinition(4)]
public IndexerBaseSettings BaseSettings { get; set; } = new IndexerBaseSettings();
[FieldDefinition(6)]
[FieldDefinition(5)]
public IndexerTorrentBaseSettings TorrentBaseSettings { get; set; } = new IndexerTorrentBaseSettings();
public NzbDroneValidationResult Validate()