From 9fab7d8328823bc6ae4d33629f467e27434b91ce Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 7 Mar 2021 23:07:12 -0500 Subject: [PATCH] History Improvements Round 1 --- frontend/src/Helpers/Props/icons.js | 2 + .../src/History/Details/HistoryDetails.js | 32 ++++++++++- .../History/Details/HistoryDetailsModal.js | 6 ++ frontend/src/History/History.js | 6 +- frontend/src/History/HistoryConnector.js | 2 +- frontend/src/History/HistoryEventTypeCell.js | 8 +++ frontend/src/History/HistoryRow.css | 12 ++++ frontend/src/History/HistoryRow.js | 30 ++++++++++ frontend/src/Search/Table/SearchIndexRow.css | 2 + frontend/src/Search/Table/SearchIndexRow.js | 7 +++ frontend/src/Store/Actions/historyActions.js | 14 ++++- .../IndexerTests/TestIndexer.cs | 5 +- src/NzbDrone.Core/History/History.cs | 5 +- src/NzbDrone.Core/History/HistoryService.cs | 55 ++++++++++++++++++- .../Definitions/BookSearchCriteria.cs | 15 +++++ .../Definitions/MovieSearchCriteria.cs | 15 +++++ .../Definitions/MusicSearchCriteria.cs | 16 ++++++ .../Definitions/SearchCriteriaBase.cs | 14 +++++ .../Definitions/TvSearchCriteria.cs | 14 +++++ .../IndexerSearch/NzbSearchService.cs | 2 +- .../Indexers/Definitions/AlphaRatio.cs | 5 +- .../Indexers/Definitions/AnimeTorrents.cs | 7 ++- .../Indexers/Definitions/Avistaz/Avistaz.cs | 4 +- .../Indexers/Definitions/BakaBT.cs | 5 +- .../BroadcastheNet/BroadcastheNet.cs | 5 +- .../Indexers/Definitions/BrokenStones.cs | 5 +- .../Indexers/Definitions/CGPeers.cs | 5 +- .../Definitions/Cardigann/Cardigann.cs | 4 +- .../Indexers/Definitions/DigitalCore.cs | 5 +- .../Indexers/Definitions/FileList/FileList.cs | 5 +- .../Indexers/Definitions/Gazelle/Gazelle.cs | 6 +- .../Indexers/Definitions/HDBits/HDBits.cs | 5 +- .../Indexers/Definitions/HDTorrents.cs | 7 ++- .../Definitions/Headphones/Headphones.cs | 5 +- .../Indexers/Definitions/IPTorrents.cs | 5 +- .../Indexers/Definitions/Milkie.cs | 5 +- .../Indexers/Definitions/MyAnonamouse.cs | 5 +- .../Indexers/Definitions/Newznab/Newznab.cs | 5 +- .../Indexers/Definitions/NotWhatCD.cs | 5 +- .../Indexers/Definitions/Orpheus.cs | 5 +- .../PassThePopcorn/PassThePopcorn.cs | 4 +- .../Indexers/Definitions/PrivateHD.cs | 5 +- .../Indexers/Definitions/Rarbg/Rarbg.cs | 5 +- .../Indexers/Definitions/Redacted.cs | 5 +- .../Indexers/Definitions/RevolutionTT.cs | 7 ++- .../Indexers/Definitions/SuperBits.cs | 5 +- .../Indexers/Definitions/TorrentDay.cs | 5 +- .../Indexers/Definitions/TorrentLeech.cs | 7 ++- .../TorrentPotato/TorrentPotato.cs | 5 +- .../Indexers/Definitions/TorrentSeeds.cs | 5 +- .../Indexers/Definitions/Torznab/Torznab.cs | 5 +- .../Indexers/Events/IndexerAuthEvent.cs | 18 ++++++ .../Indexers/Events/IndexerCapsEvent.cs | 16 ++++++ src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 17 +++++- 54 files changed, 395 insertions(+), 79 deletions(-) create mode 100644 src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs create mode 100644 src/NzbDrone.Core/Indexers/Events/IndexerCapsEvent.cs diff --git a/frontend/src/Helpers/Props/icons.js b/frontend/src/Helpers/Props/icons.js index 3c57c7a6b..499ba4a87 100644 --- a/frontend/src/Helpers/Props/icons.js +++ b/frontend/src/Helpers/Props/icons.js @@ -70,6 +70,7 @@ import { faLanguage as fasLanguage, faLaptop as fasLaptop, faLevelUpAlt as fasLevelUpAlt, + faLock as fasLock, faMedkit as fasMedkit, faMinus as fasMinus, faPause as fasPause, @@ -167,6 +168,7 @@ export const IN_CINEMAS = fasTicketAlt; export const INFO = fasInfoCircle; export const INTERACTIVE = fasUser; export const KEYBOARD = farKeyboard; +export const LOCK = fasLock; export const LOGOUT = fasSignOutAlt; export const MEDIA_INFO = farFileInvoice; export const MISSING = fasExclamationTriangle; diff --git a/frontend/src/History/Details/HistoryDetails.js b/frontend/src/History/Details/HistoryDetails.js index 9d2fea5d1..ad5504ba2 100644 --- a/frontend/src/History/Details/HistoryDetails.js +++ b/frontend/src/History/Details/HistoryDetails.js @@ -12,7 +12,7 @@ function HistoryDetails(props) { data } = props; - if (eventType === 'indexerQuery') { + if (eventType === 'indexerQuery' || eventType === 'indexerRss') { const { query, queryResults, @@ -65,7 +65,8 @@ function HistoryDetails(props) { if (eventType === 'releaseGrabbed') { const { - source + source, + title } = data; return ( @@ -82,7 +83,32 @@ function HistoryDetails(props) { !!data && + } + + { + !!data && + + } + + ); + } + + if (eventType === 'indexerAuth') { + return ( + + { + !!indexer && + } diff --git a/frontend/src/History/Details/HistoryDetailsModal.js b/frontend/src/History/Details/HistoryDetailsModal.js index 26d0b9957..e6f960c48 100644 --- a/frontend/src/History/Details/HistoryDetailsModal.js +++ b/frontend/src/History/Details/HistoryDetailsModal.js @@ -16,6 +16,12 @@ function getHeaderTitle(eventType) { switch (eventType) { case 'indexerQuery': return 'Indexer Query'; + case 'releaseGrabbed': + return 'Release Grabbed'; + case 'indexerAuth': + return 'Indexer Auth Attempt'; + case 'indexerRss': + return 'Indexer Rss Query'; default: return 'Unknown'; } diff --git a/frontend/src/History/History.js b/frontend/src/History/History.js index 82823a459..fd31bdfb7 100644 --- a/frontend/src/History/History.js +++ b/frontend/src/History/History.js @@ -27,7 +27,7 @@ class History extends Component { error, isMoviesFetching, isMoviesPopulated, - moviesError, + indexersError, items, columns, selectedFilterKey, @@ -40,7 +40,7 @@ class History extends Component { const isFetchingAny = isFetching || isMoviesFetching; const isAllPopulated = isPopulated && (isMoviesPopulated || !items.length); - const hasError = error || moviesError; + const hasError = error || indexersError; return ( @@ -140,7 +140,7 @@ History.propTypes = { error: PropTypes.object, isMoviesFetching: PropTypes.bool.isRequired, isMoviesPopulated: PropTypes.bool.isRequired, - moviesError: PropTypes.object, + indexersError: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, selectedFilterKey: PropTypes.string.isRequired, diff --git a/frontend/src/History/HistoryConnector.js b/frontend/src/History/HistoryConnector.js index 259123fe6..bd4308afc 100644 --- a/frontend/src/History/HistoryConnector.js +++ b/frontend/src/History/HistoryConnector.js @@ -15,7 +15,7 @@ function createMapStateToProps() { return { isMoviesFetching: indexers.isFetching, isMoviesPopulated: indexers.isPopulated, - moviesError: indexers.error, + indexersError: indexers.error, ...history }; } diff --git a/frontend/src/History/HistoryEventTypeCell.js b/frontend/src/History/HistoryEventTypeCell.js index c072b231c..ee4e648bb 100644 --- a/frontend/src/History/HistoryEventTypeCell.js +++ b/frontend/src/History/HistoryEventTypeCell.js @@ -11,6 +11,10 @@ function getIconName(eventType) { return icons.SEARCH; case 'releaseGrabbed': return icons.DOWNLOAD; + case 'indexerAuth': + return icons.LOCK; + case 'indexerRss': + return icons.RSS; default: return icons.UNKNOWN; } @@ -31,6 +35,10 @@ function getTooltip(eventType, data, indexer) { return `Query "${data.query}" sent to ${indexer.name}`; case 'releaseGrabbed': return `Release grabbed from ${indexer.name}`; + case 'indexerAuth': + return `Auth attempted for ${indexer.name}`; + case 'indexerRss': + return `RSS query for ${indexer.name}`; default: return 'Unknown event'; } diff --git a/frontend/src/History/HistoryRow.css b/frontend/src/History/HistoryRow.css index 003ede75b..d63040c59 100644 --- a/frontend/src/History/HistoryRow.css +++ b/frontend/src/History/HistoryRow.css @@ -16,6 +16,18 @@ width: 110px; } +.categories { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 110px; +} + +.source { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 110px; +} + .details { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/History/HistoryRow.js b/frontend/src/History/HistoryRow.js index 3287732e4..54499ba1c 100644 --- a/frontend/src/History/HistoryRow.js +++ b/frontend/src/History/HistoryRow.js @@ -117,6 +117,21 @@ class HistoryRow extends Component { ); } + if (name === 'categories') { + return ( + + { + data.categories ? + data.categories : + null + } + + ); + } + if (name === 'successful') { return ( + { + data.source ? + data.source : + null + } + + ); + } + if (name === 'elapsedTime') { return ( + + ); } diff --git a/frontend/src/Store/Actions/historyActions.js b/frontend/src/Store/Actions/historyActions.js index 82eaaca0d..b416b5c25 100644 --- a/frontend/src/Store/Actions/historyActions.js +++ b/frontend/src/Store/Actions/historyActions.js @@ -46,6 +46,12 @@ export const defaultState = { isSortable: false, isVisible: true }, + { + name: 'categories', + label: 'Categories', + isSortable: false, + isVisible: true + }, { name: 'date', label: translate('Date'), @@ -56,7 +62,13 @@ export const defaultState = { name: 'successful', label: 'Successful', isSortable: false, - isVisible: true + isVisible: false + }, + { + name: 'source', + label: 'Source', + isSortable: false, + isVisible: false }, { name: 'elapsedTime', diff --git a/src/NzbDrone.Core.Test/IndexerTests/TestIndexer.cs b/src/NzbDrone.Core.Test/IndexerTests/TestIndexer.cs index 6246380bc..1d7522ec8 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TestIndexer.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TestIndexer.cs @@ -2,6 +2,7 @@ using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Test.IndexerTests { @@ -17,8 +18,8 @@ namespace NzbDrone.Core.Test.IndexerTests public int _supportedPageSize; public override int PageSize => _supportedPageSize; - public TestIndexer(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public TestIndexer(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/History/History.cs b/src/NzbDrone.Core/History/History.cs index 0071fe252..09b9b03a7 100644 --- a/src/NzbDrone.Core/History/History.cs +++ b/src/NzbDrone.Core/History/History.cs @@ -23,6 +23,9 @@ namespace NzbDrone.Core.History { Unknown = 0, ReleaseGrabbed = 1, - IndexerQuery = 2 + IndexerQuery = 2, + IndexerRss = 3, + IndexerAuth = 4, + IndexerCapabilities = 5 } } diff --git a/src/NzbDrone.Core/History/HistoryService.cs b/src/NzbDrone.Core/History/HistoryService.cs index dcd4c807d..85253ead9 100644 --- a/src/NzbDrone.Core/History/HistoryService.cs +++ b/src/NzbDrone.Core/History/HistoryService.cs @@ -5,6 +5,8 @@ using NLog; using NzbDrone.Core.Datastore; using NzbDrone.Core.Indexers; using NzbDrone.Core.Indexers.Events; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider.Events; @@ -26,7 +28,8 @@ namespace NzbDrone.Core.History public class HistoryService : IHistoryService, IHandle>, IHandle, - IHandle + IHandle, + IHandle { private readonly IHistoryRepository _historyRepository; private readonly Logger _logger; @@ -88,11 +91,42 @@ namespace NzbDrone.Core.History { Date = DateTime.UtcNow, IndexerId = message.IndexerId, - EventType = HistoryEventType.IndexerQuery + EventType = message.Query.RssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery }; + if (message.Query is MovieSearchCriteria) + { + history.Data.Add("ImdbId", ((MovieSearchCriteria)message.Query).ImdbId ?? string.Empty); + history.Data.Add("TmdbId", ((MovieSearchCriteria)message.Query).TmdbId?.ToString() ?? string.Empty); + history.Data.Add("TraktId", ((MovieSearchCriteria)message.Query).TraktId?.ToString() ?? string.Empty); + } + + if (message.Query is TvSearchCriteria) + { + history.Data.Add("ImdbId", ((TvSearchCriteria)message.Query).ImdbId ?? string.Empty); + history.Data.Add("TvdbId", ((TvSearchCriteria)message.Query).TvdbId?.ToString() ?? string.Empty); + history.Data.Add("TraktId", ((TvSearchCriteria)message.Query).TraktId?.ToString() ?? string.Empty); + history.Data.Add("RId", ((TvSearchCriteria)message.Query).RId?.ToString() ?? string.Empty); + history.Data.Add("TvMazeId", ((TvSearchCriteria)message.Query).TvMazeId?.ToString() ?? string.Empty); + history.Data.Add("Season", ((TvSearchCriteria)message.Query).Season?.ToString() ?? string.Empty); + history.Data.Add("Episode", ((TvSearchCriteria)message.Query).Episode ?? string.Empty); + } + + if (message.Query is MusicSearchCriteria) + { + history.Data.Add("Artist", ((MusicSearchCriteria)message.Query).Artist ?? string.Empty); + history.Data.Add("Album", ((MusicSearchCriteria)message.Query).Album ?? string.Empty); + } + + if (message.Query is BookSearchCriteria) + { + history.Data.Add("Author", ((BookSearchCriteria)message.Query).Author ?? string.Empty); + history.Data.Add("Title", ((BookSearchCriteria)message.Query).Title ?? string.Empty); + } + history.Data.Add("ElapsedTime", message.Time.ToString()); history.Data.Add("Query", message.Query.SearchTerm ?? string.Empty); + history.Data.Add("QueryType", message.Query.SearchType ?? string.Empty); history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty); history.Data.Add("Source", message.Query.Source ?? string.Empty); history.Data.Add("Successful", message.Successful.ToString()); @@ -112,12 +146,27 @@ namespace NzbDrone.Core.History history.Data.Add("Successful", message.Successful.ToString()); history.Data.Add("Source", message.Source ?? string.Empty); - history.Data.Add("GrabMethod", message.Redirect ? "Proxy" : "Redirect"); + history.Data.Add("GrabMethod", message.Redirect ? "Redirect" : "Proxy"); history.Data.Add("Title", message.Title); _historyRepository.Insert(history); } + public void Handle(IndexerAuthEvent message) + { + var history = new History + { + Date = DateTime.UtcNow, + IndexerId = message.IndexerId, + EventType = HistoryEventType.IndexerAuth + }; + + history.Data.Add("Successful", message.Successful.ToString()); + history.Data.Add("ElapsedTime", message.Time.ToString()); + + _historyRepository.Insert(history); + } + public void Handle(ProviderDeletedEvent message) { _historyRepository.DeleteForIndexers(new List { message.ProviderId }); diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs index ca2a2d180..9ae52049e 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/BookSearchCriteria.cs @@ -1,8 +1,23 @@ +using NzbDrone.Common.Extensions; + namespace NzbDrone.Core.IndexerSearch.Definitions { public class BookSearchCriteria : SearchCriteriaBase { public string Author { get; set; } public string Title { get; set; } + + public override bool RssSearch + { + get + { + if (SearchTerm.IsNullOrWhiteSpace() && Author.IsNullOrWhiteSpace() && Title.IsNullOrWhiteSpace()) + { + return true; + } + + return false; + } + } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/MovieSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/MovieSearchCriteria.cs index 6fd9ffd09..d785ea42c 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/MovieSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/MovieSearchCriteria.cs @@ -1,3 +1,5 @@ +using NzbDrone.Common.Extensions; + namespace NzbDrone.Core.IndexerSearch.Definitions { public class MovieSearchCriteria : SearchCriteriaBase @@ -5,5 +7,18 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public string ImdbId { get; set; } public int? TmdbId { get; set; } public int? TraktId { get; set; } + + public override bool RssSearch + { + get + { + if (SearchTerm.IsNullOrWhiteSpace() && ImdbId.IsNullOrWhiteSpace() && !TmdbId.HasValue && !TraktId.HasValue) + { + return true; + } + + return false; + } + } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/MusicSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/MusicSearchCriteria.cs index c9bb2bf17..6e1b25f7c 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/MusicSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/MusicSearchCriteria.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using NzbDrone.Common.Extensions; + namespace NzbDrone.Core.IndexerSearch.Definitions { public class MusicSearchCriteria : SearchCriteriaBase @@ -5,5 +8,18 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public string Album { get; set; } public string Artist { get; set; } public string Label { get; set; } + + public override bool RssSearch + { + get + { + if (SearchTerm.IsNullOrWhiteSpace() && Album.IsNullOrWhiteSpace() && Artist.IsNullOrWhiteSpace() && Label.IsNullOrWhiteSpace()) + { + return true; + } + + return false; + } + } } } diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index e4932c0de..7153c0d7d 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; +using NzbDrone.Common.Extensions; namespace NzbDrone.Core.IndexerSearch.Definitions { @@ -24,6 +25,19 @@ namespace NzbDrone.Core.IndexerSearch.Definitions return $"{{Term: {SearchTerm}, Offset: {Offset ?? 0}, Limit: {Limit ?? 0}, Categories: [{string.Join(", ", Categories)}]}}"; } + public virtual bool RssSearch + { + get + { + if (SearchTerm.IsNullOrWhiteSpace()) + { + return true; + } + + return false; + } + } + public string SanitizedSearchTerm { get diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs index a47cae7ca..d7b87ef3a 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/TvSearchCriteria.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using NzbDrone.Common.Extensions; using NzbDrone.Core.Parser; @@ -19,6 +20,19 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public string SanitizedTvSearchString => (SanitizedSearchTerm + " " + EpisodeSearchString).Trim(); public string EpisodeSearchString => GetEpisodeSearchString(); + public override bool RssSearch + { + get + { + if (SearchTerm.IsNullOrWhiteSpace() && ImdbId.IsNullOrWhiteSpace() && !TvdbId.HasValue && !RId.HasValue && !TraktId.HasValue && !TvMazeId.HasValue) + { + return true; + } + + return false; + } + } + private string GetEpisodeSearchString() { if (Season == 0) diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 620ea110d..8b068cf87 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -156,7 +156,7 @@ namespace NzbDrone.Core.IndexerSearch .ToList(); } - _logger.ProgressInfo("Searching {0} indexers for {1}", indexers.Count, criteriaBase.SearchTerm); + _logger.ProgressInfo("Searching {0} indexers for {1}", indexers.Count, criteriaBase.ToString()); var tasks = indexers.Select(x => DispatchIndexer(searchAction, x, criteriaBase)); diff --git a/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs b/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs index f451ef385..881c5eadf 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AlphaRatio.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://alpharatio.cc/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public AlphaRatio(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public AlphaRatio(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs index f5abfcc88..2cbf6d0de 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs @@ -13,6 +13,7 @@ using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -30,8 +31,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public AnimeTorrents(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public AnimeTorrents(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } @@ -68,7 +69,7 @@ namespace NzbDrone.Core.Indexers.Definitions .SetHeader("Content-Type", "multipart/form-data") .Build(); - var response = await _httpClient.ExecuteAsync(authLoginRequest); + var response = await ExecuteAuth(authLoginRequest); if (response.Content != null && response.Content.Contains("logout.php")) { diff --git a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/Avistaz.cs b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/Avistaz.cs index 1b6aa36bb..068935ff8 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/Avistaz.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/Avistaz.cs @@ -5,6 +5,7 @@ using FluentValidation.Results; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions.Avistaz { @@ -21,10 +22,11 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz public Avistaz(IIndexerRepository indexerRepository, IHttpClient httpClient, + IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { _indexerRepository = indexerRepository; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs index 23dea7db0..70a437cdf 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs @@ -15,6 +15,7 @@ using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -31,8 +32,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public BakaBT(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public BakaBT(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs index 31468ec2c..53160130b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNet.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.BroadcastheNet { @@ -18,8 +19,8 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet public override string BaseUrl => "http://api.broadcasthe.net/"; - public BroadcastheNet(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public BroadcastheNet(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BrokenStones.cs b/src/NzbDrone.Core/Indexers/Definitions/BrokenStones.cs index c98351eb3..70a4fc4f9 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BrokenStones.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BrokenStones.cs @@ -1,6 +1,7 @@ using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -10,8 +11,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://brokenstones.club/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public BrokenStones(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public BrokenStones(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/CGPeers.cs b/src/NzbDrone.Core/Indexers/Definitions/CGPeers.cs index e2da3edfb..952b0c678 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/CGPeers.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/CGPeers.cs @@ -1,6 +1,7 @@ using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -10,8 +11,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://cgpeers.to/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public CGPeers(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public CGPeers(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs index f714fe866..189932102 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/Cardigann.cs @@ -8,6 +8,7 @@ using NzbDrone.Common.Cache; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerVersions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -60,11 +61,12 @@ namespace NzbDrone.Core.Indexers.Cardigann public Cardigann(IIndexerDefinitionUpdateService definitionService, IHttpClient httpClient, + IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, ICacheManager cacheManager, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { _definitionService = definitionService; _generatorCache = cacheManager.GetRollingCache(GetType(), "CardigannGeneratorCache", TimeSpan.FromMinutes(5)); diff --git a/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs b/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs index b3842b975..cb8a515a3 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/DigitalCore.cs @@ -13,6 +13,7 @@ using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -28,8 +29,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public DigitalCore(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public DigitalCore(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileList.cs b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileList.cs index 3f3a90cfe..d10d68927 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileList.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileList.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.FileList { @@ -16,8 +17,8 @@ namespace NzbDrone.Core.Indexers.FileList public override bool SupportsRedirect => true; public override IndexerCapabilities Capabilities => SetCapabilities(); - public FileList(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public FileList(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs index 9adf2a836..b285c73b5 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Gazelle { @@ -17,10 +18,11 @@ namespace NzbDrone.Core.Indexers.Gazelle public override IndexerCapabilities Capabilities => SetCapabilities(); public Gazelle(IHttpClient httpClient, + IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } @@ -69,7 +71,7 @@ namespace NzbDrone.Core.Indexers.Gazelle .Accept(HttpAccept.Json) .Build(); - var response = await _httpClient.ExecuteAsync(authLoginRequest); + var response = await ExecuteAuth(authLoginRequest); cookies = response.GetCookies(); diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBits.cs b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBits.cs index 8deaf10c4..d2880e49d 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBits.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBits.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.HDBits { @@ -16,8 +17,8 @@ namespace NzbDrone.Core.Indexers.HDBits public override int PageSize => 30; - public HDBits(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public HDBits(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs index a443f11d0..a969345e5 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs @@ -12,6 +12,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -29,8 +30,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public HDTorrents(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public HDTorrents(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } @@ -63,7 +64,7 @@ namespace NzbDrone.Core.Indexers.Definitions .SetHeader("Content-Type", "multipart/form-data") .Build(); - var response = await _httpClient.ExecuteAsync(authLoginRequest); + var response = await ExecuteAuth(authLoginRequest); cookies = response.GetCookies(); UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30)); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Headphones/Headphones.cs b/src/NzbDrone.Core/Indexers/Definitions/Headphones/Headphones.cs index e12d52aca..9504007a7 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Headphones/Headphones.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Headphones/Headphones.cs @@ -6,6 +6,7 @@ using FluentValidation.Results; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Headphones { @@ -34,8 +35,8 @@ namespace NzbDrone.Core.Indexers.Headphones return new HeadphonesRssParser(Capabilities.Categories); } - public Headphones(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Headphones(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs index 963f23d6f..621eab2db 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/IPTorrents.cs @@ -10,6 +10,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -26,8 +27,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public IPTorrents(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public IPTorrents(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Milkie.cs b/src/NzbDrone.Core/Indexers/Definitions/Milkie.cs index 420396218..ef73fde51 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Milkie.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Milkie.cs @@ -8,6 +8,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -24,8 +25,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public Milkie(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Milkie(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/MyAnonamouse.cs b/src/NzbDrone.Core/Indexers/Definitions/MyAnonamouse.cs index 7cfe000d0..964d8647f 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/MyAnonamouse.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/MyAnonamouse.cs @@ -10,6 +10,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -26,8 +27,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public MyAnonamouse(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public MyAnonamouse(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs index 845bd52a4..8ca99de96 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/Newznab.cs @@ -7,6 +7,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -97,8 +98,8 @@ namespace NzbDrone.Core.Indexers.Newznab } } - public Newznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Newznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { _capabilitiesProvider = capabilitiesProvider; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/NotWhatCD.cs b/src/NzbDrone.Core/Indexers/Definitions/NotWhatCD.cs index 2c31c8291..c3319cd2b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/NotWhatCD.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/NotWhatCD.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://notwhat.cd/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public NotWhatCD(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public NotWhatCD(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs index a504002bb..9fb388ed6 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Orpheus.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://orpheus.network/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public Orpheus(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Orpheus(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcorn.cs b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcorn.cs index 246aee811..ecec80aa2 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcorn.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcorn.cs @@ -3,6 +3,7 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.PassThePopcorn { @@ -20,11 +21,12 @@ namespace NzbDrone.Core.Indexers.PassThePopcorn public override int PageSize => 50; public PassThePopcorn(IHttpClient httpClient, + IEventAggregator eventAggregator, ICacheManager cacheManager, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/PrivateHD.cs b/src/NzbDrone.Core/Indexers/Definitions/PrivateHD.cs index 0eb30fd12..27116eb99 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PrivateHD.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PrivateHD.cs @@ -3,6 +3,7 @@ using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Definitions.Avistaz; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -12,8 +13,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://privatehd.to/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public PrivateHD(IIndexerRepository indexerRepository, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(indexerRepository, httpClient, indexerStatusService, configService, logger) + public PrivateHD(IIndexerRepository indexerRepository, IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(indexerRepository, httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs index 1ed3cd692..0c99a156c 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Rarbg/Rarbg.cs @@ -6,6 +6,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Exceptions; using NzbDrone.Core.Http.CloudFlare; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Indexers.Rarbg @@ -25,8 +26,8 @@ namespace NzbDrone.Core.Indexers.Rarbg public override TimeSpan RateLimit => TimeSpan.FromSeconds(2); - public Rarbg(IRarbgTokenProvider tokenProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Rarbg(IRarbgTokenProvider tokenProvider, IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { _tokenProvider = tokenProvider; } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs index 992dd40e4..aabfd1846 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.Definitions { @@ -11,8 +12,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override string BaseUrl => "https://redacted.ch/"; public override IndexerPrivacy Privacy => IndexerPrivacy.Private; - public Redacted(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Redacted(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs b/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs index e2b419a2f..61f26203d 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs @@ -14,6 +14,7 @@ using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -31,8 +32,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public RevolutionTT(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public RevolutionTT(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } @@ -68,7 +69,7 @@ namespace NzbDrone.Core.Indexers.Definitions .SetHeader("Content-Type", "multipart/form-data") .Build(); - var response = await _httpClient.ExecuteAsync(authLoginRequest); + var response = await ExecuteAuth(authLoginRequest); if (response.Content != null && response.Content.Contains("/logout.php")) { diff --git a/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs b/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs index bb1873f5b..fb51fbb52 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SuperBits.cs @@ -11,6 +11,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -27,8 +28,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public SuperBits(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public SuperBits(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentDay.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentDay.cs index 22b58b101..9be07a848 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentDay.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentDay.cs @@ -9,6 +9,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -25,8 +26,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public TorrentDay(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public TorrentDay(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs index 72b35568f..cf4dc2de6 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs @@ -13,6 +13,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -30,8 +31,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public TorrentLeech(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public TorrentLeech(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } @@ -64,7 +65,7 @@ namespace NzbDrone.Core.Indexers.Definitions .SetHeader("Content-Type", "multipart/form-data") .Build(); - var response = await _httpClient.ExecuteAsync(authLoginRequest); + var response = await ExecuteAuth(authLoginRequest); cookies = response.GetCookies(); UpdateCookies(cookies, DateTime.Now + TimeSpan.FromDays(30)); diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentPotato/TorrentPotato.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentPotato/TorrentPotato.cs index d819752db..da0df9110 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentPotato/TorrentPotato.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentPotato/TorrentPotato.cs @@ -2,6 +2,7 @@ using System; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.Indexers.TorrentPotato { @@ -14,8 +15,8 @@ namespace NzbDrone.Core.Indexers.TorrentPotato public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override TimeSpan RateLimit => TimeSpan.FromSeconds(2); - public TorrentPotato(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public TorrentPotato(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs index 8461e854e..a73ea5e74 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs @@ -12,6 +12,7 @@ using NzbDrone.Common.Http; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -30,8 +31,8 @@ namespace NzbDrone.Core.Indexers.Definitions public override IndexerPrivacy Privacy => IndexerPrivacy.Private; public override IndexerCapabilities Capabilities => SetCapabilities(); - public TorrentSeeds(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public TorrentSeeds(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { } diff --git a/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs index 439b03772..da2fd23f0 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Torznab/Torznab.cs @@ -8,6 +8,7 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Newznab; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; @@ -48,8 +49,8 @@ namespace NzbDrone.Core.Indexers.Torznab } } - public Torznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) - : base(httpClient, indexerStatusService, configService, logger) + public Torznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + : base(httpClient, eventAggregator, indexerStatusService, configService, logger) { _capabilitiesProvider = capabilitiesProvider; } diff --git a/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs b/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs new file mode 100644 index 000000000..ed515b3b0 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs @@ -0,0 +1,18 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Indexers.Events +{ + public class IndexerAuthEvent : IEvent + { + public int IndexerId { get; set; } + public bool Successful { get; set; } + public long Time { get; set; } + + public IndexerAuthEvent(int indexerId, bool successful, long time) + { + IndexerId = indexerId; + Successful = successful; + Time = time; + } + } +} diff --git a/src/NzbDrone.Core/Indexers/Events/IndexerCapsEvent.cs b/src/NzbDrone.Core/Indexers/Events/IndexerCapsEvent.cs new file mode 100644 index 000000000..7755c6463 --- /dev/null +++ b/src/NzbDrone.Core/Indexers/Events/IndexerCapsEvent.cs @@ -0,0 +1,16 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Indexers.Events +{ + public class IndexerCapsEvent : IEvent + { + public int IndexerId { get; set; } + public bool Successful { get; set; } + + public IndexerCapsEvent(int indexerId, bool successful) + { + IndexerId = indexerId; + Successful = successful; + } + } +} diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index 0eb99fdda..b53b1fa52 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -10,8 +10,10 @@ using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; using NzbDrone.Core.Http.CloudFlare; +using NzbDrone.Core.Indexers.Events; using NzbDrone.Core.Indexers.Exceptions; using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; @@ -23,6 +25,7 @@ namespace NzbDrone.Core.Indexers protected const int MaxNumResultsPerQuery = 1000; protected readonly IHttpClient _httpClient; + protected readonly IEventAggregator _eventAggregator; public IDictionary Cookies { get; set; } public override bool SupportsRss => true; @@ -37,10 +40,11 @@ namespace NzbDrone.Core.Indexers public abstract IIndexerRequestGenerator GetRequestGenerator(); public abstract IParseIndexerResponse GetParser(); - public HttpIndexerBase(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) + public HttpIndexerBase(IHttpClient httpClient, IEventAggregator eventAggregator, IIndexerStatusService indexerStatusService, IConfigService configService, Logger logger) : base(indexerStatusService, configService, logger) { _httpClient = httpClient; + _eventAggregator = eventAggregator; } public override Task Fetch(MovieSearchCriteria searchCriteria) @@ -477,6 +481,17 @@ namespace NzbDrone.Core.Indexers return new IndexerResponse(request, response, stopWatch.ElapsedMilliseconds); } + protected HttpResponse ExecuteAuth(HttpRequest request) + { + var stopWatch = Stopwatch.StartNew(); + var response = _httpClient.Execute(request); + stopWatch.Stop(); + + _eventAggregator.PublishEvent(new IndexerAuthEvent(Definition.Id, !response.HasHttpError, stopWatch.ElapsedMilliseconds)); + + return response; + } + protected override async Task Test(List failures) { failures.AddIfNotNull(await TestConnection());