Misc Fixes

This commit is contained in:
Qstick
2021-02-19 22:29:47 -05:00
parent b3990d647c
commit 0afb01962f
21 changed files with 79 additions and 89 deletions

View File

@@ -56,8 +56,8 @@
margin-top: 0; margin-top: 0;
} }
.externalLinks { .externalLink {
margin: 0 2px; composes: link from '~Components/Link/Link.css';
width: 22px;
text-align: center; color: $textColor;
} }

View File

@@ -14,9 +14,9 @@ import translate from 'Utilities/String/translate';
import CapabilitiesLabel from './CapabilitiesLabel'; import CapabilitiesLabel from './CapabilitiesLabel';
import IndexerStatusCell from './IndexerStatusCell'; import IndexerStatusCell from './IndexerStatusCell';
import ProtocolLabel from './ProtocolLabel'; import ProtocolLabel from './ProtocolLabel';
import styles from './MovieIndexRow.css'; import styles from './IndexerIndexRow.css';
class MovieIndexRow extends Component { class IndexerIndexRow extends Component {
// //
// Lifecycle // Lifecycle
@@ -61,6 +61,7 @@ class MovieIndexRow extends Component {
const { const {
id, id,
name, name,
baseUrl,
enable, enable,
tags, tags,
protocol, protocol,
@@ -213,8 +214,10 @@ class MovieIndexRow extends Component {
className={styles[column.name]} className={styles[column.name]}
> >
<IconButton <IconButton
className={styles.externalLink}
name={icons.EXTERNAL_LINK} name={icons.EXTERNAL_LINK}
title={'Website'} title={'Website'}
to={baseUrl}
/> />
<IconButton <IconButton
@@ -247,8 +250,9 @@ class MovieIndexRow extends Component {
} }
} }
MovieIndexRow.propTypes = { IndexerIndexRow.propTypes = {
id: PropTypes.number.isRequired, id: PropTypes.number.isRequired,
baseUrl: PropTypes.string.isRequired,
protocol: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired,
privacy: PropTypes.string.isRequired, privacy: PropTypes.string.isRequired,
priority: PropTypes.number.isRequired, priority: PropTypes.number.isRequired,
@@ -267,8 +271,8 @@ MovieIndexRow.propTypes = {
timeFormat: PropTypes.string.isRequired timeFormat: PropTypes.string.isRequired
}; };
MovieIndexRow.defaultProps = { IndexerIndexRow.defaultProps = {
tags: [] tags: []
}; };
export default MovieIndexRow; export default IndexerIndexRow;

View File

@@ -5,8 +5,8 @@ import VirtualTableRow from 'Components/Table/VirtualTableRow';
import { sortDirections } from 'Helpers/Props'; import { sortDirections } from 'Helpers/Props';
import MovieIndexItemConnector from 'Indexer/Index/MovieIndexItemConnector'; import MovieIndexItemConnector from 'Indexer/Index/MovieIndexItemConnector';
import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter';
import IndexerIndexRow from './IndexerIndexRow';
import MovieIndexHeaderConnector from './MovieIndexHeaderConnector'; import MovieIndexHeaderConnector from './MovieIndexHeaderConnector';
import MovieIndexRow from './MovieIndexRow';
import styles from './MovieIndexTable.css'; import styles from './MovieIndexTable.css';
class MovieIndexTable extends Component { class MovieIndexTable extends Component {
@@ -62,7 +62,7 @@ class MovieIndexTable extends Component {
> >
<MovieIndexItemConnector <MovieIndexItemConnector
key={movie.id} key={movie.id}
component={MovieIndexRow} component={IndexerIndexRow}
columns={columns} columns={columns}
indexerId={movie.id} indexerId={movie.id}
isSelected={selectedState[movie.id]} isSelected={selectedState[movie.id]}

View File

@@ -58,6 +58,12 @@
margin-top: 0; margin-top: 0;
} }
.downloadLink {
composes: link from '~Components/Link/Link.css';
color: $textColor;
}
.externalLinks { .externalLinks {
margin: 0 2px; margin: 0 2px;
width: 22px; width: 22px;

View File

@@ -215,6 +215,7 @@ class SearchIndexRow extends Component {
className={styles[column.name]} className={styles[column.name]}
> >
<IconButton <IconButton
className={styles.downloadLink}
name={icons.DOWNLOAD} name={icons.DOWNLOAD}
title={'Grab'} title={'Grab'}
to={downloadUrl} to={downloadUrl}

View File

@@ -81,7 +81,7 @@ export const defaultState = {
filters: [] filters: []
}, },
{ {
key: 'grabbed', key: 'releaseGrabbed',
label: translate('Grabbed'), label: translate('Grabbed'),
filters: [ filters: [
{ {
@@ -92,56 +92,12 @@ export const defaultState = {
] ]
}, },
{ {
key: 'imported', key: 'indexerQuery',
label: translate('Imported'), label: translate('IndexerQuery'),
filters: [ filters: [
{ {
key: 'eventType', key: 'eventType',
value: '3', value: '2',
type: filterTypes.EQUAL
}
]
},
{
key: 'failed',
label: translate('Failed'),
filters: [
{
key: 'eventType',
value: '4',
type: filterTypes.EQUAL
}
]
},
{
key: 'deleted',
label: translate('Deleted'),
filters: [
{
key: 'eventType',
value: '6',
type: filterTypes.EQUAL
}
]
},
{
key: 'renamed',
label: translate('Renamed'),
filters: [
{
key: 'eventType',
value: '8',
type: filterTypes.EQUAL
}
]
},
{
key: 'ignored',
label: translate('Ignored'),
filters: [
{
key: 'eventType',
value: '9',
type: filterTypes.EQUAL type: filterTypes.EQUAL
} }
] ]

View File

@@ -40,6 +40,7 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<IndexerDefinition>("Indexers").RegisterModel() Mapper.Entity<IndexerDefinition>("Indexers").RegisterModel()
.Ignore(x => x.ImplementationName) .Ignore(x => x.ImplementationName)
.Ignore(i => i.BaseUrl)
.Ignore(i => i.Protocol) .Ignore(i => i.Protocol)
.Ignore(i => i.Privacy) .Ignore(i => i.Privacy)
.Ignore(i => i.SupportsRss) .Ignore(i => i.SupportsRss)

View File

@@ -15,7 +15,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
private readonly IIndexerDefinitionUpdateService _definitionService; private readonly IIndexerDefinitionUpdateService _definitionService;
public override string Name => "Cardigann"; 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 DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override IndexerPrivacy Privacy => IndexerPrivacy.Private; 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) protected override void Test(List<ValidationFailure> failures)
{ {
base.Test(failures); base.Test(failures);

View File

@@ -155,15 +155,10 @@ namespace NzbDrone.Core.Indexers.Cardigann
return variables; return variables;
} }
private void Authenticate() public void DoLogin()
{ {
var login = _definition.Login; var login = _definition.Login;
if (login == null || TestLogin())
{
return;
}
if (login.Method == "post") if (login.Method == "post")
{ {
var pairs = new Dictionary<string, string>(); 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 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) if (response.HasHttpRedirect)
{ {
@@ -745,6 +740,9 @@ namespace NzbDrone.Core.Indexers.Cardigann
return false; return false;
} }
var parser = new HtmlParser();
var document = parser.ParseDocument(response.Content);
if (_definition.Login.Test.Selector != null) if (_definition.Login.Test.Selector != null)
{ {
var selection = document.QuerySelectorAll(_definition.Login.Test.Selector); 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) private IEnumerable<IndexerRequest> GetRequest(Dictionary<string, object> variables)
{ {
Cookies = GetCookies();
if (Cookies == null || !Cookies.Any())
{
Authenticate();
}
var search = _definition.Search; var search = _definition.Search;
var mappedCategories = MapTorznabCapsToTrackers((int[])variables[".Query.Categories"]); 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; request.HttpRequest.Method = method;
yield return request; yield return request;

View File

@@ -72,8 +72,6 @@ namespace NzbDrone.Core.Indexers.Gazelle
cookies = response.GetCookies(); cookies = response.GetCookies();
Cookies = cookies;
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30)); UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
_logger.Debug("Gazelle authentication succeeded."); _logger.Debug("Gazelle authentication succeeded.");

View File

@@ -65,7 +65,6 @@ namespace NzbDrone.Core.Indexers.Definitions
var response = _httpClient.Execute(authLoginRequest); var response = _httpClient.Execute(authLoginRequest);
cookies = response.GetCookies(); cookies = response.GetCookies();
Cookies = cookies;
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30)); UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
_logger.Debug("HDTorrents authentication succeeded."); _logger.Debug("HDTorrents authentication succeeded.");

View File

@@ -304,6 +304,7 @@ namespace NzbDrone.Core.Indexers.Definitions
Title = title, Title = title,
Guid = details.AbsoluteUri, Guid = details.AbsoluteUri,
DownloadUrl = link.AbsoluteUri, DownloadUrl = link.AbsoluteUri,
InfoUrl = details.AbsoluteUri,
PublishDate = publishDate, PublishDate = publishDate,
Category = cat, Category = cat,
Size = size, Size = size,

View File

@@ -16,7 +16,7 @@ namespace NzbDrone.Core.Indexers.Newznab
private readonly INewznabCapabilitiesProvider _capabilitiesProvider; private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
public override string Name => "Newznab"; public override string Name => "Newznab";
public override string BaseUrl => Settings.BaseUrl; public override string BaseUrl => GetBaseUrlFromSettings();
public override bool FollowRedirect => true; public override bool FollowRedirect => true;
public override DownloadProtocol Protocol => DownloadProtocol.Usenet; public override DownloadProtocol Protocol => DownloadProtocol.Usenet;
@@ -40,6 +40,18 @@ namespace NzbDrone.Core.Indexers.Newznab
return new NewznabRssParser(Settings); 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() public IndexerCapabilities GetCapabilitiesFromSettings()
{ {
var caps = new IndexerCapabilities(); var caps = new IndexerCapabilities();

View File

@@ -242,6 +242,7 @@ namespace NzbDrone.Core.Indexers.Definitions
Title = title, Title = title,
Guid = details.AbsoluteUri, Guid = details.AbsoluteUri,
DownloadUrl = link.AbsoluteUri, DownloadUrl = link.AbsoluteUri,
InfoUrl = details.AbsoluteUri,
PublishDate = publishDate, PublishDate = publishDate,
Category = _categories.MapTrackerCatToNewznab(row.c.ToString()), Category = _categories.MapTrackerCatToNewznab(row.c.ToString()),
Size = (long)row.size, Size = (long)row.size,

View File

@@ -66,7 +66,6 @@ namespace NzbDrone.Core.Indexers.Definitions
var response = _httpClient.Execute(authLoginRequest); var response = _httpClient.Execute(authLoginRequest);
cookies = response.GetCookies(); cookies = response.GetCookies();
Cookies = cookies;
UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30)); UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30));
_logger.Debug("TorrentLeech authentication succeeded."); _logger.Debug("TorrentLeech authentication succeeded.");

View File

@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Indexers.Torznab
private readonly INewznabCapabilitiesProvider _capabilitiesProvider; private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
public override string Name => "Torznab"; public override string Name => "Torznab";
public override string BaseUrl => Settings.BaseUrl; public override string BaseUrl => "";
public override DownloadProtocol Protocol => DownloadProtocol.Torrent; public override DownloadProtocol Protocol => DownloadProtocol.Torrent;
public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerPrivacy Privacy => IndexerPrivacy.Private;

View File

@@ -136,7 +136,7 @@ namespace NzbDrone.Core.Indexers
generator.CookiesUpdater = (cookies, expiration) => generator.CookiesUpdater = (cookies, expiration) =>
{ {
_indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration); UpdateCookies(cookies, expiration);
}; };
return generator; return generator;
@@ -156,6 +156,7 @@ namespace NzbDrone.Core.Indexers
protected void UpdateCookies(IDictionary<string, string> cookies, DateTime? expiration) protected void UpdateCookies(IDictionary<string, string> cookies, DateTime? expiration)
{ {
Cookies = cookies;
_indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration); _indexerStatusService.UpdateCookies(Definition.Id, cookies, expiration);
} }
@@ -434,6 +435,8 @@ namespace NzbDrone.Core.Indexers
response = _httpClient.Execute(request.HttpRequest); response = _httpClient.Execute(request.HttpRequest);
} }
UpdateCookies(Cookies, DateTime.Now + TimeSpan.FromDays(30));
return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds); return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds);
} }

View File

@@ -10,6 +10,7 @@ namespace NzbDrone.Core.Indexers
bool SupportsSearch { get; } bool SupportsSearch { get; }
IndexerCapabilities Capabilities { get; } IndexerCapabilities Capabilities { get; }
string BaseUrl { get; }
DownloadProtocol Protocol { get; } DownloadProtocol Protocol { get; }
IndexerPrivacy Privacy { get; } IndexerPrivacy Privacy { get; }

View File

@@ -7,6 +7,7 @@ namespace NzbDrone.Core.Indexers
{ {
public class IndexerDefinition : ProviderDefinition public class IndexerDefinition : ProviderDefinition
{ {
public string BaseUrl { get; set; }
public DownloadProtocol Protocol { get; set; } public DownloadProtocol Protocol { get; set; }
public IndexerPrivacy Privacy { get; set; } public IndexerPrivacy Privacy { get; set; }
public bool SupportsRss { get; set; } public bool SupportsRss { get; set; }

View File

@@ -52,6 +52,7 @@ namespace NzbDrone.Core.Indexers
var settings = (CardigannSettings)definition.Settings; var settings = (CardigannSettings)definition.Settings;
var defFile = _definitionService.GetDefinition(settings.DefinitionFile); var defFile = _definitionService.GetDefinition(settings.DefinitionFile);
definition.ExtraFields = defFile.Settings; definition.ExtraFields = defFile.Settings;
definition.BaseUrl = defFile.Links.First();
definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public; definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public;
definition.Capabilities = new IndexerCapabilities(); definition.Capabilities = new IndexerCapabilities();
definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes); definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes);
@@ -71,6 +72,7 @@ namespace NzbDrone.Core.Indexers
var settings = (CardigannSettings)definition.Settings; var settings = (CardigannSettings)definition.Settings;
var defFile = _definitionService.GetDefinition(settings.DefinitionFile); var defFile = _definitionService.GetDefinition(settings.DefinitionFile);
definition.ExtraFields = defFile.Settings; definition.ExtraFields = defFile.Settings;
definition.BaseUrl = defFile.Links.First();
definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public; definition.Privacy = defFile.Type == "private" ? IndexerPrivacy.Private : IndexerPrivacy.Public;
definition.Capabilities = new IndexerCapabilities(); definition.Capabilities = new IndexerCapabilities();
definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes); definition.Capabilities.ParseCardigannSearchModes(defFile.Caps.Modes);
@@ -158,6 +160,7 @@ namespace NzbDrone.Core.Indexers
//We want to use the definition Caps and Privacy for Cardigann instead of the provider. //We want to use the definition Caps and Privacy for Cardigann instead of the provider.
if (definition.Implementation != typeof(Cardigann.Cardigann).Name) if (definition.Implementation != typeof(Cardigann.Cardigann).Name)
{ {
definition.BaseUrl = provider.BaseUrl;
definition.Privacy = provider.Privacy; definition.Privacy = provider.Privacy;
definition.Capabilities = provider.Capabilities; definition.Capabilities = provider.Capabilities;
} }

View File

@@ -10,6 +10,7 @@ namespace Prowlarr.Api.V1.Indexers
{ {
public class IndexerResource : ProviderResource public class IndexerResource : ProviderResource
{ {
public string BaseUrl { get; set; }
public bool Enable { get; set; } public bool Enable { get; set; }
public bool SupportsRss { get; set; } public bool SupportsRss { get; set; }
public bool SupportsSearch { get; set; } public bool SupportsSearch { get; set; }
@@ -49,6 +50,7 @@ namespace Prowlarr.Api.V1.Indexers
} }
} }
resource.BaseUrl = definition.BaseUrl;
resource.Enable = definition.Enable; resource.Enable = definition.Enable;
resource.SupportsRss = definition.SupportsRss; resource.SupportsRss = definition.SupportsRss;
resource.SupportsSearch = definition.SupportsSearch; resource.SupportsSearch = definition.SupportsSearch;
@@ -85,6 +87,7 @@ namespace Prowlarr.Api.V1.Indexers
} }
definition.Enable = resource.Enable; definition.Enable = resource.Enable;
definition.BaseUrl = resource.BaseUrl;
definition.Priority = resource.Priority; definition.Priority = resource.Priority;
definition.Privacy = resource.Privacy; definition.Privacy = resource.Privacy;
definition.Added = resource.Added; definition.Added = resource.Added;