mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-26 23:06:43 -04:00
Misc Fixes
This commit is contained in:
@@ -15,7 +15,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
private readonly IIndexerDefinitionUpdateService _definitionService;
|
||||
|
||||
public override string Name => "Cardigann";
|
||||
public override string BaseUrl => throw new System.NotImplementedException();
|
||||
public override string BaseUrl => "";
|
||||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
|
||||
@@ -76,6 +76,24 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool CheckIfLoginNeeded(HttpResponse httpResponse)
|
||||
{
|
||||
var generator = (CardigannRequestGenerator)GetRequestGenerator();
|
||||
|
||||
SetCookieFunctions(generator);
|
||||
|
||||
return generator.CheckIfLoginIsNeeded(httpResponse);
|
||||
}
|
||||
|
||||
protected override void DoLogin()
|
||||
{
|
||||
var generator = (CardigannRequestGenerator)GetRequestGenerator();
|
||||
|
||||
SetCookieFunctions(generator);
|
||||
|
||||
generator.DoLogin();
|
||||
}
|
||||
|
||||
protected override void Test(List<ValidationFailure> failures)
|
||||
{
|
||||
base.Test(failures);
|
||||
|
||||
@@ -155,15 +155,10 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
return variables;
|
||||
}
|
||||
|
||||
private void Authenticate()
|
||||
public void DoLogin()
|
||||
{
|
||||
var login = _definition.Login;
|
||||
|
||||
if (login == null || TestLogin())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (login.Method == "post")
|
||||
{
|
||||
var pairs = new Dictionary<string, string>();
|
||||
@@ -725,7 +720,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
|
||||
protected string GetRedirectDomainHint(HttpResponse result) => GetRedirectDomainHint(result.Request.Url.ToString(), result.Headers.GetSingleValue("Location"));
|
||||
|
||||
protected bool CheckIfLoginIsNeeded(HttpResponse response, IHtmlDocument document)
|
||||
public bool CheckIfLoginIsNeeded(HttpResponse response)
|
||||
{
|
||||
if (response.HasHttpRedirect)
|
||||
{
|
||||
@@ -745,6 +740,9 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
return false;
|
||||
}
|
||||
|
||||
var parser = new HtmlParser();
|
||||
var document = parser.ParseDocument(response.Content);
|
||||
|
||||
if (_definition.Login.Test.Selector != null)
|
||||
{
|
||||
var selection = document.QuerySelectorAll(_definition.Login.Test.Selector);
|
||||
@@ -759,13 +757,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
|
||||
private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variables)
|
||||
{
|
||||
Cookies = GetCookies();
|
||||
|
||||
if (Cookies == null || !Cookies.Any())
|
||||
{
|
||||
Authenticate();
|
||||
}
|
||||
|
||||
var search = _definition.Search;
|
||||
|
||||
var mappedCategories = MapTorznabCapsToTrackers((int[])variables[".Query.Categories"]);
|
||||
@@ -890,14 +881,6 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
||||
}
|
||||
}
|
||||
|
||||
if (Cookies != null)
|
||||
{
|
||||
foreach (var cookie in Cookies)
|
||||
{
|
||||
request.HttpRequest.Cookies.Add(cookie.Key, cookie.Value);
|
||||
}
|
||||
}
|
||||
|
||||
request.HttpRequest.Method = method;
|
||||
|
||||
yield return request;
|
||||
|
||||
@@ -72,8 +72,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
|
||||
|
||||
cookies = response.GetCookies();
|
||||
|
||||
Cookies = cookies;
|
||||
|
||||
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
|
||||
|
||||
_logger.Debug("Gazelle authentication succeeded.");
|
||||
|
||||
@@ -65,7 +65,6 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
var response = _httpClient.Execute(authLoginRequest);
|
||||
|
||||
cookies = response.GetCookies();
|
||||
Cookies = cookies;
|
||||
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
|
||||
|
||||
_logger.Debug("HDTorrents authentication succeeded.");
|
||||
|
||||
@@ -304,6 +304,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
Title = title,
|
||||
Guid = details.AbsoluteUri,
|
||||
DownloadUrl = link.AbsoluteUri,
|
||||
InfoUrl = details.AbsoluteUri,
|
||||
PublishDate = publishDate,
|
||||
Category = cat,
|
||||
Size = size,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
|
||||
|
||||
public override string Name => "Newznab";
|
||||
public override string BaseUrl => Settings.BaseUrl;
|
||||
public override string BaseUrl => GetBaseUrlFromSettings();
|
||||
public override bool FollowRedirect => true;
|
||||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
|
||||
@@ -40,6 +40,18 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
return new NewznabRssParser(Settings);
|
||||
}
|
||||
|
||||
public string GetBaseUrlFromSettings()
|
||||
{
|
||||
var baseUrl = "";
|
||||
|
||||
if (Definition == null || Settings == null || Settings.Categories == null)
|
||||
{
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
return Settings.BaseUrl;
|
||||
}
|
||||
|
||||
public IndexerCapabilities GetCapabilitiesFromSettings()
|
||||
{
|
||||
var caps = new IndexerCapabilities();
|
||||
|
||||
@@ -242,6 +242,7 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
Title = title,
|
||||
Guid = details.AbsoluteUri,
|
||||
DownloadUrl = link.AbsoluteUri,
|
||||
InfoUrl = details.AbsoluteUri,
|
||||
PublishDate = publishDate,
|
||||
Category = _categories.MapTrackerCatToNewznab(row.c.ToString()),
|
||||
Size = (long)row.size,
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
var response = _httpClient.Execute(authLoginRequest);
|
||||
|
||||
cookies = response.GetCookies();
|
||||
Cookies = cookies;
|
||||
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
|
||||
|
||||
_logger.Debug("TorrentLeech authentication succeeded.");
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Indexers.Torznab
|
||||
private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
|
||||
|
||||
public override string Name => "Torznab";
|
||||
public override string BaseUrl => Settings.BaseUrl;
|
||||
public override string BaseUrl => "";
|
||||
|
||||
public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
|
||||
public override IndexerPrivacy Privacy => IndexerPrivacy.Private;
|
||||
|
||||
Reference in New Issue
Block a user