mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-26 23:06:43 -04:00
More AnimeTorrents work
This commit is contained in:
@@ -10,6 +10,7 @@ using NLog;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers.Exceptions;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
@@ -45,17 +46,19 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
protected override void DoLogin()
|
||||
{
|
||||
UpdateCookies(null, null);
|
||||
|
||||
var requestBuilder = new HttpRequestBuilder(LoginUrl)
|
||||
{
|
||||
LogResponseContent = true
|
||||
LogResponseContent = true,
|
||||
AllowAutoRedirect = true
|
||||
};
|
||||
|
||||
var loginPage = _httpClient.Execute(new HttpRequest(LoginUrl));
|
||||
requestBuilder.Method = HttpMethod.POST;
|
||||
requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15);
|
||||
requestBuilder.SetCookies(loginPage.GetCookies());
|
||||
|
||||
var cookies = Cookies;
|
||||
|
||||
Cookies = null;
|
||||
var authLoginRequest = requestBuilder
|
||||
.AddFormParameter("username", Settings.Username)
|
||||
.AddFormParameter("password", Settings.Password)
|
||||
@@ -66,10 +69,16 @@ namespace NzbDrone.Core.Indexers.Definitions
|
||||
|
||||
var response = _httpClient.Execute(authLoginRequest);
|
||||
|
||||
cookies = response.GetCookies();
|
||||
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
|
||||
if (response.Content != null && response.Content.Contains("logout.php"))
|
||||
{
|
||||
UpdateCookies(response.GetCookies(), DateTime.Now + TimeSpan.FromDays(30));
|
||||
|
||||
_logger.Debug("AnimeTorrents authentication succeeded.");
|
||||
_logger.Debug("AnimeTorrents authentication succeeded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IndexerAuthException("AnimeTorrents authentication failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool CheckIfLoginNeeded(HttpResponse httpResponse)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet
|
||||
switch (indexerResponse.HttpResponse.StatusCode)
|
||||
{
|
||||
case HttpStatusCode.Unauthorized:
|
||||
throw new ApiKeyException("API Key invalid or not authorized");
|
||||
throw new IndexerAuthException("API Key invalid or not authorized");
|
||||
case HttpStatusCode.NotFound:
|
||||
throw new IndexerException(indexerResponse, "Indexer API call returned NotFound, the Indexer API may have changed.");
|
||||
case HttpStatusCode.ServiceUnavailable:
|
||||
|
||||
@@ -35,12 +35,12 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
|
||||
if (code >= 100 && code <= 199)
|
||||
{
|
||||
throw new ApiKeyException(errorMessage);
|
||||
throw new IndexerAuthException(errorMessage);
|
||||
}
|
||||
|
||||
if (!indexerResponse.Request.Url.FullUri.Contains("apikey=") && (errorMessage == "Missing parameter" || errorMessage.Contains("apikey")))
|
||||
{
|
||||
throw new ApiKeyException("Indexer requires an API key");
|
||||
throw new IndexerAuthException("Indexer requires an API key");
|
||||
}
|
||||
|
||||
if (errorMessage == "Request limit reached")
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace NzbDrone.Core.Indexers.Torznab
|
||||
|
||||
if (code >= 100 && code <= 199)
|
||||
{
|
||||
throw new ApiKeyException("Invalid API key");
|
||||
throw new IndexerAuthException("Invalid API key");
|
||||
}
|
||||
|
||||
if (!indexerResponse.Request.Url.FullUri.Contains("apikey=") && errorMessage == "Missing parameter")
|
||||
{
|
||||
throw new ApiKeyException("Indexer requires an API key");
|
||||
throw new IndexerAuthException("Indexer requires an API key");
|
||||
}
|
||||
|
||||
if (errorMessage == "Request limit reached")
|
||||
|
||||
Reference in New Issue
Block a user