From 27d65937c061af4862f51f0f6c61625b9be8faa2 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 2 Dec 2017 00:03:12 -0500 Subject: [PATCH] UI Updates, Separate Auto and Manual Searches per Indexer --- .../AddNewArtist/AddNewArtistModalContent.js | 48 ++++++++----------- .../ImportArtist/Import/ImportArtistFooter.js | 2 - .../Form/MonitorAlbumsSelectInput.js | 10 ++-- frontend/src/Helpers/Props/icons.js | 2 +- .../Indexers/EditIndexerModalContent.js | 24 ++++++++-- .../src/Settings/Indexers/Indexers/Indexer.js | 19 ++++++-- .../EditNotificationModalContent.js | 4 +- .../src/Store/Actions/albumStudioActions.js | 2 +- .../AlbumStudio/AlbumStudioModule.cs | 21 ++------ src/Lidarr.Api.V1/Indexers/IndexerResource.cs | 13 +++-- src/Lidarr.Api.V1/Indexers/ReleaseModule.cs | 2 +- .../Checks/IndexerSearchCheckFixture.cs | 48 ++++++++++++++++--- .../ArtistSearchServiceFixture.cs | 4 +- ...parate_automatic_and_interactive_search.cs | 19 ++++++++ .../HealthCheck/Checks/IndexerSearchCheck.cs | 15 ++++-- .../IndexerSearch/AlbumSearchService.cs | 4 +- .../IndexerSearch/ArtistSearchService.cs | 4 +- .../Definitions/SearchCriteriaBase.cs | 1 + .../IndexerSearch/NzbSearchService.cs | 31 +++++++----- src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs | 3 +- src/NzbDrone.Core/Indexers/IndexerBase.cs | 3 +- .../Indexers/IndexerDefinition.cs | 7 +-- src/NzbDrone.Core/Indexers/IndexerFactory.cs | 19 ++++++-- src/NzbDrone.Core/Indexers/Newznab/Newznab.cs | 3 +- src/NzbDrone.Core/Indexers/Torznab/Torznab.cs | 3 +- .../Music/AlbumMonitoredService.cs | 10 +--- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + .../IntegrationTest.cs | 3 +- 28 files changed, 205 insertions(+), 120 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js index d9028e15b..a6a6084ad 100644 --- a/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js @@ -153,33 +153,27 @@ class AddNewArtistModalContent extends Component { /> - { - showLanguageProfile && - - Language Profile - - - - } - - { - showMetadataProfile && - - Metadata Profile - - - - } + + Language Profile + + + + + + Metadata Profile + + + Album Folder diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js index 0b42e25b5..2e4440620 100644 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js @@ -162,7 +162,6 @@ class ImportArtistFooter extends Component { { showLanguageProfile && -
Language Profile @@ -181,7 +180,6 @@ class ImportArtistFooter extends Component { { showMetadataProfile && -
Metadata Profile diff --git a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js index 71f39a146..14075f9f9 100644 --- a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js +++ b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js @@ -4,11 +4,11 @@ import SelectInput from './SelectInput'; const monitorOptions = [ { key: 'all', value: 'All Albums' }, - { key: 'future', value: 'Future Albums' }, - { key: 'missing', value: 'Missing Albums' }, - { key: 'existing', value: 'Existing Albums' }, - { key: 'first', value: 'Only First Album' }, - { key: 'latest', value: 'Only Latest Album' }, + // { key: 'future', value: 'Future Albums' }, + // { key: 'missing', value: 'Missing Albums' }, + // { key: 'existing', value: 'Existing Albums' }, + // { key: 'first', value: 'Only First Album' }, + // { key: 'latest', value: 'Only Latest Album' }, { key: 'none', value: 'None' } ]; diff --git a/frontend/src/Helpers/Props/icons.js b/frontend/src/Helpers/Props/icons.js index a84e6475e..4086646de 100644 --- a/frontend/src/Helpers/Props/icons.js +++ b/frontend/src/Helpers/Props/icons.js @@ -23,7 +23,7 @@ export const COMPUTER = 'fa fa-desktop'; export const DANGER = 'fa fa-exclamation-circle'; export const DELETE = 'fa fa-trash'; export const DOWNLOAD = 'fa fa-download'; -export const DOWNLOADED = 'fa fa-inbox'; +export const DOWNLOADED = 'fa fa-download'; export const DOWNLOADING = 'fa fa-cloud-download'; export const DRIVE = 'fa fa-hdd-o'; export const EDIT = 'fa fa-wrench'; diff --git a/frontend/src/Settings/Indexers/Indexers/EditIndexerModalContent.js b/frontend/src/Settings/Indexers/Indexers/EditIndexerModalContent.js index 00b41730c..c267994ea 100644 --- a/frontend/src/Settings/Indexers/Indexers/EditIndexerModalContent.js +++ b/frontend/src/Settings/Indexers/Indexers/EditIndexerModalContent.js @@ -37,7 +37,8 @@ function EditIndexerModalContent(props) { id, name, enableRss, - enableSearch, + enableAutomaticSearch, + enableInteractiveSearch, supportsRss, supportsSearch, fields @@ -90,14 +91,29 @@ function EditIndexerModalContent(props) { - Enable Search + Enable Automatic Search + + + + Enable Interactive Search + + diff --git a/frontend/src/Settings/Indexers/Indexers/Indexer.js b/frontend/src/Settings/Indexers/Indexers/Indexer.js index 221a6a239..379e818b8 100644 --- a/frontend/src/Settings/Indexers/Indexers/Indexer.js +++ b/frontend/src/Settings/Indexers/Indexers/Indexer.js @@ -67,7 +67,8 @@ class Indexer extends Component { id, name, enableRss, - enableSearch, + enableAutomaticSearch, + enableInteractiveSearch, supportsRss, supportsSearch } = this.props; @@ -90,10 +91,17 @@ class Indexer extends Component { + +
@@ -122,7 +130,8 @@ Indexer.propTypes = { id: PropTypes.number.isRequired, name: PropTypes.string.isRequired, enableRss: PropTypes.bool.isRequired, - enableSearch: PropTypes.bool.isRequired, + enableAutomaticSearch: PropTypes.bool.isRequired, + enableInteractiveSearch: PropTypes.bool.isRequired, supportsRss: PropTypes.bool.isRequired, supportsSearch: PropTypes.bool.isRequired, onConfirmDeleteIndexer: PropTypes.func.isRequired diff --git a/frontend/src/Settings/Notifications/Notifications/EditNotificationModalContent.js b/frontend/src/Settings/Notifications/Notifications/EditNotificationModalContent.js index f375275f2..be0be92bb 100644 --- a/frontend/src/Settings/Notifications/Notifications/EditNotificationModalContent.js +++ b/frontend/src/Settings/Notifications/Notifications/EditNotificationModalContent.js @@ -107,12 +107,12 @@ function EditNotificationModalContent(props) { - On Download + On Import UpdateAll(); } @@ -33,20 +33,7 @@ namespace Lidarr.Api.V1.AlbumStudio artist.Monitored = s.Monitored.Value; } - if (s.Albums != null && s.Albums.Any()) - { - foreach (var artistAlbum in artist.Albums) - { - var album = s.Albums.FirstOrDefault(c => c.Id == artistAlbum.Id); - - if (album != null) - { - artistAlbum.Monitored = album.Monitored; - } - } - } - - _episodeMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions); + _albumMonitoredService.SetAlbumMonitoredStatus(artist, request.MonitoringOptions); } return "ok".AsResponse(HttpStatusCode.Accepted); diff --git a/src/Lidarr.Api.V1/Indexers/IndexerResource.cs b/src/Lidarr.Api.V1/Indexers/IndexerResource.cs index 85c1824c8..2b63db913 100644 --- a/src/Lidarr.Api.V1/Indexers/IndexerResource.cs +++ b/src/Lidarr.Api.V1/Indexers/IndexerResource.cs @@ -1,11 +1,12 @@ -using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers; namespace Lidarr.Api.V1.Indexers { public class IndexerResource : ProviderResource { public bool EnableRss { get; set; } - public bool EnableSearch { get; set; } + public bool EnableAutomaticSearch { get; set; } + public bool EnableInteractiveSearch { get; set; } public bool SupportsRss { get; set; } public bool SupportsSearch { get; set; } public DownloadProtocol Protocol { get; set; } @@ -20,7 +21,8 @@ namespace Lidarr.Api.V1.Indexers var resource = base.ToResource(definition); resource.EnableRss = definition.EnableRss; - resource.EnableSearch = definition.EnableSearch; + resource.EnableAutomaticSearch = definition.EnableAutomaticSearch; + resource.EnableInteractiveSearch = definition.EnableInteractiveSearch; resource.SupportsRss = definition.SupportsRss; resource.SupportsSearch = definition.SupportsSearch; resource.Protocol = definition.Protocol; @@ -35,9 +37,10 @@ namespace Lidarr.Api.V1.Indexers var definition = base.ToModel(resource); definition.EnableRss = resource.EnableRss; - definition.EnableSearch = resource.EnableSearch; + definition.EnableAutomaticSearch = resource.EnableAutomaticSearch; + definition.EnableInteractiveSearch = resource.EnableInteractiveSearch; return definition; } } -} \ No newline at end of file +} diff --git a/src/Lidarr.Api.V1/Indexers/ReleaseModule.cs b/src/Lidarr.Api.V1/Indexers/ReleaseModule.cs index 6a049212f..7583fc00f 100644 --- a/src/Lidarr.Api.V1/Indexers/ReleaseModule.cs +++ b/src/Lidarr.Api.V1/Indexers/ReleaseModule.cs @@ -89,7 +89,7 @@ namespace Lidarr.Api.V1.Indexers { try { - var decisions = _nzbSearchService.AlbumSearch(albumId, true, true); + var decisions = _nzbSearchService.AlbumSearch(albumId, true, true, true); var prioritizedDecisions = _prioritizeDownloadDecision.PrioritizeDecisions(decisions); return MapDecisions(prioritizedDecisions); diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs index 8cbc28b9d..030d8a8db 100644 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs +++ b/src/NzbDrone.Core.Test/HealthCheck/Checks/IndexerSearchCheckFixture.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Moq; using NUnit.Framework; using NzbDrone.Core.HealthCheck.Checks; @@ -20,7 +20,11 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks .Returns(new List()); Mocker.GetMock() - .Setup(s => s.SearchEnabled(It.IsAny())) + .Setup(s => s.AutomaticSearchEnabled(It.IsAny())) + .Returns(new List()); + + Mocker.GetMock() + .Setup(s => s.InteractiveSearchEnabled(It.IsAny())) .Returns(new List()); } @@ -35,17 +39,28 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks .Returns(new List { _indexerMock.Object }); } - private void GivenSearchEnabled() + private void GivenAutomaticSearchEnabled() { Mocker.GetMock() - .Setup(s => s.SearchEnabled(It.IsAny())) + .Setup(s => s.AutomaticSearchEnabled(It.IsAny())) + .Returns(new List { _indexerMock.Object }); + } + + private void GivenInteractiveSearchEnabled() + { + Mocker.GetMock() + .Setup(s => s.InteractiveSearchEnabled(It.IsAny())) .Returns(new List { _indexerMock.Object }); } private void GivenSearchFiltered() { Mocker.GetMock() - .Setup(s => s.SearchEnabled(false)) + .Setup(s => s.AutomaticSearchEnabled(false)) + .Returns(new List { _indexerMock.Object }); + + Mocker.GetMock() + .Setup(s => s.InteractiveSearchEnabled(false)) .Returns(new List { _indexerMock.Object }); } @@ -64,14 +79,33 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks } [Test] - public void should_return_ok_when_search_is_enabled() + public void should_return_ok_when_automatic_and__search_is_enabled() { GivenIndexer(false, true); - GivenSearchEnabled(); + GivenAutomaticSearchEnabled(); + GivenInteractiveSearchEnabled(); Subject.Check().ShouldBeOk(); } + [Test] + public void should_return_warning_when_only_automatic_search_is_enabled() + { + GivenIndexer(false, true); + GivenAutomaticSearchEnabled(); + + Subject.Check().ShouldBeWarning(); + } + + [Test] + public void should_return_warning_when_only_interactive_search_is_enabled() + { + GivenIndexer(false, true); + GivenInteractiveSearchEnabled(); + + Subject.Check().ShouldBeWarning(); + } + [Test] public void should_return_warning_if_search_is_supported_but_disabled() { diff --git a/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs b/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs index 1bfc87813..2a3723451 100644 --- a/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerSearchTests/ArtistSearchServiceFixture.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests .Returns(_artist); Mocker.GetMock() - .Setup(s => s.ArtistSearch(_artist.Id, false, true)) + .Setup(s => s.ArtistSearch(_artist.Id, false, true, false)) .Returns(new List()); Mocker.GetMock() @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.IndexerSearchTests Subject.Execute(new ArtistSearchCommand {ArtistId = _artist.Id, Trigger = CommandTrigger.Manual}); Mocker.GetMock() - .Verify(v => v.ArtistSearch(_artist.Id, false, true), + .Verify(v => v.ArtistSearch(_artist.Id, false, true, false), Times.Exactly(_artist.Albums.Count(s => s.Monitored))); } } diff --git a/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs b/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs new file mode 100644 index 000000000..3f03f8207 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/006_separate_automatic_and_interactive_search.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(6)] + public class separate_automatic_and_interactive_search : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Rename.Column("EnableSearch").OnTable("Indexers").To("EnableAutomaticSearch"); + Alter.Table("Indexers").AddColumn("EnableInteractiveSearch").AsBoolean().Nullable(); + + Execute.Sql("UPDATE Indexers SET EnableInteractiveSearch = EnableAutomaticSearch"); + + Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsBoolean().NotNullable(); + } + } +} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs index 220c08c0e..0e3ebec72 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/IndexerSearchCheck.cs @@ -19,14 +19,21 @@ namespace NzbDrone.Core.HealthCheck.Checks public override HealthCheck Check() { - var enabled = _indexerFactory.SearchEnabled(false); + var automaticSearchEnabled = _indexerFactory.AutomaticSearchEnabled(false); - if (enabled.Empty()) + if (automaticSearchEnabled.Empty()) { - return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Search enabled, Lidarr will not provide any search results"); + return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Automatic Search enabled, Lidarr will not provide any automatic search results"); } - var active = _indexerFactory.SearchEnabled(true); + var interactiveSearchEnabled = _indexerFactory.InteractiveSearchEnabled(false); + + if (interactiveSearchEnabled.Empty()) + { + return new HealthCheck(GetType(), HealthCheckResult.Warning, "No indexers available with Interactive Search enabled, Lidarr will not provide any interactive search results"); + } + + var active = _indexerFactory.AutomaticSearchEnabled(true); if (active.Empty()) { diff --git a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs b/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs index f34a5422b..71e2a6ff3 100644 --- a/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/AlbumSearchService.cs @@ -44,7 +44,7 @@ namespace NzbDrone.Core.IndexerSearch foreach (var album in albums) { List decisions; - decisions = _nzbSearchService.AlbumSearch(album.Id, false, userInvokedSearch); + decisions = _nzbSearchService.AlbumSearch(album.Id, false, userInvokedSearch, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); downloadedCount += processed.Grabbed.Count; @@ -59,7 +59,7 @@ namespace NzbDrone.Core.IndexerSearch foreach (var albumId in message.AlbumIds) { var decisions = - _nzbSearchService.AlbumSearch(albumId, false, message.Trigger == CommandTrigger.Manual); + _nzbSearchService.AlbumSearch(albumId, false, message.Trigger == CommandTrigger.Manual, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); _logger.ProgressInfo("Album search completed. {0} reports downloaded.", processed.Grabbed.Count); diff --git a/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs index 14006766f..2e3cc5ccb 100644 --- a/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ArtistSearchService.cs @@ -1,4 +1,4 @@ -using NLog; +using NLog; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Download; using NzbDrone.Core.Messaging.Commands; @@ -22,7 +22,7 @@ namespace NzbDrone.Core.IndexerSearch public void Execute(ArtistSearchCommand message) { - var decisions = _nzbSearchService.ArtistSearch(message.ArtistId, false, message.Trigger == CommandTrigger.Manual); + var decisions = _nzbSearchService.ArtistSearch(message.ArtistId, false, message.Trigger == CommandTrigger.Manual, false); var processed = _processDownloadDecisions.ProcessDecisions(decisions); _logger.ProgressInfo("Artist search completed. {0} reports downloaded.", processed.Grabbed.Count); diff --git a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs index 965b5d87c..b24aad1b5 100644 --- a/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs +++ b/src/NzbDrone.Core/IndexerSearch/Definitions/SearchCriteriaBase.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public virtual bool MonitoredEpisodesOnly { get; set; } public virtual bool UserInvokedSearch { get; set; } + public virtual bool InteractiveSearch { get; set; } public Artist Artist { get; set; } public List Albums { get; set; } diff --git a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index e129db351..47a2657bf 100644 --- a/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -16,8 +16,8 @@ namespace NzbDrone.Core.IndexerSearch { public interface ISearchForNzb { - List AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch); - List ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch); + List AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch); + List ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch); } public class NzbSearchService : ISearchForNzb @@ -41,21 +41,21 @@ namespace NzbDrone.Core.IndexerSearch _logger = logger; } - public List AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch) + public List AlbumSearch(int albumId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var album = _albumService.GetAlbum(albumId); - return AlbumSearch(album, missingOnly, userInvokedSearch); + return AlbumSearch(album, missingOnly, userInvokedSearch, interactiveSearch); } - public List ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch) + public List ArtistSearch(int artistId, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var artist = _artistService.GetArtist(artistId); - return ArtistSearch(artist, missingOnly, userInvokedSearch); + return ArtistSearch(artist, missingOnly, userInvokedSearch, interactiveSearch); } - public List ArtistSearch(Artist artist, bool missingOnly, bool userInvokedSearch) + public List ArtistSearch(Artist artist, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { - var searchSpec = Get(artist, userInvokedSearch); + var searchSpec = Get(artist, userInvokedSearch, interactiveSearch); var albums = _albumService.GetAlbumsByArtist(artist.Id); searchSpec.Albums = albums; @@ -63,11 +63,11 @@ namespace NzbDrone.Core.IndexerSearch return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - public List AlbumSearch(Album album, bool missingOnly, bool userInvokedSearch) + public List AlbumSearch(Album album, bool missingOnly, bool userInvokedSearch, bool interactiveSearch) { var artist = _artistService.GetArtist(album.ArtistId); - var searchSpec = Get(artist, new List { album }, userInvokedSearch); + var searchSpec = Get(artist, new List { album }, userInvokedSearch, interactiveSearch); searchSpec.AlbumTitle = album.Title; if (album.ReleaseDate.HasValue) @@ -78,29 +78,34 @@ namespace NzbDrone.Core.IndexerSearch return Dispatch(indexer => indexer.Fetch(searchSpec), searchSpec); } - private TSpec Get(Artist artist, List albums, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() + private TSpec Get(Artist artist, List albums, bool userInvokedSearch, bool interactiveSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec(); spec.Albums = albums; spec.Artist = artist; spec.UserInvokedSearch = userInvokedSearch; + spec.InteractiveSearch = interactiveSearch; return spec; } - private static TSpec Get(Artist artist, bool userInvokedSearch) where TSpec : SearchCriteriaBase, new() + private static TSpec Get(Artist artist, bool userInvokedSearch, bool interactiveSearch) where TSpec : SearchCriteriaBase, new() { var spec = new TSpec(); spec.Artist = artist; spec.UserInvokedSearch = userInvokedSearch; + spec.InteractiveSearch = interactiveSearch; return spec; } private List Dispatch(Func> searchAction, SearchCriteriaBase criteriaBase) { - var indexers = _indexerFactory.SearchEnabled(); + var indexers = criteriaBase.InteractiveSearch ? + _indexerFactory.InteractiveSearchEnabled() : + _indexerFactory.AutomaticSearchEnabled(); + var reports = new List(); _logger.ProgressInfo("Searching {0} indexers for {1}", indexers.Count, criteriaBase); diff --git a/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs b/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs index 603d7ed85..84aa25202 100644 --- a/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs +++ b/src/NzbDrone.Core/Indexers/Gazelle/Gazelle.cs @@ -61,7 +61,8 @@ namespace NzbDrone.Core.Indexers.Gazelle return new IndexerDefinition { EnableRss = false, - EnableSearch = false, + EnableAutomaticSearch = false, + EnableInteractiveSearch = false, Name = name, Implementation = GetType().Name, Settings = settings, diff --git a/src/NzbDrone.Core/Indexers/IndexerBase.cs b/src/NzbDrone.Core/Indexers/IndexerBase.cs index 6894b4af3..63726ccf1 100644 --- a/src/NzbDrone.Core/Indexers/IndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/IndexerBase.cs @@ -48,7 +48,8 @@ namespace NzbDrone.Core.Indexers { Name = GetType().Name, EnableRss = config.Validate().IsValid && SupportsRss, - EnableSearch = config.Validate().IsValid && SupportsSearch, + EnableAutomaticSearch = config.Validate().IsValid && SupportsSearch, + EnableInteractiveSearch = config.Validate().IsValid && SupportsSearch, Implementation = GetType().Name, Settings = config }; diff --git a/src/NzbDrone.Core/Indexers/IndexerDefinition.cs b/src/NzbDrone.Core/Indexers/IndexerDefinition.cs index 229d35948..019a61727 100644 --- a/src/NzbDrone.Core/Indexers/IndexerDefinition.cs +++ b/src/NzbDrone.Core/Indexers/IndexerDefinition.cs @@ -1,16 +1,17 @@ -using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.ThingiProvider; namespace NzbDrone.Core.Indexers { public class IndexerDefinition : ProviderDefinition { public bool EnableRss { get; set; } - public bool EnableSearch { get; set; } + public bool EnableAutomaticSearch { get; set; } + public bool EnableInteractiveSearch { get; set; } public DownloadProtocol Protocol { get; set; } public bool SupportsRss { get; set; } public bool SupportsSearch { get; set; } - public override bool Enable => EnableRss || EnableSearch; + public override bool Enable => EnableRss || EnableAutomaticSearch || EnableInteractiveSearch; public IndexerStatus Status { get; set; } } diff --git a/src/NzbDrone.Core/Indexers/IndexerFactory.cs b/src/NzbDrone.Core/Indexers/IndexerFactory.cs index ba1c9a347..902de54b9 100644 --- a/src/NzbDrone.Core/Indexers/IndexerFactory.cs +++ b/src/NzbDrone.Core/Indexers/IndexerFactory.cs @@ -11,7 +11,8 @@ namespace NzbDrone.Core.Indexers public interface IIndexerFactory : IProviderFactory { List RssEnabled(bool filterBlockedIndexers = true); - List SearchEnabled(bool filterBlockedIndexers = true); + List AutomaticSearchEnabled(bool filterBlockedIndexers = true); + List InteractiveSearchEnabled(bool filterBlockedIndexers = true); } public class IndexerFactory : ProviderFactory, IIndexerFactory @@ -57,9 +58,21 @@ namespace NzbDrone.Core.Indexers return enabledIndexers.ToList(); } - public List SearchEnabled(bool filterBlockedIndexers = true) + public List AutomaticSearchEnabled(bool filterBlockedIndexers = true) { - var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableSearch); + var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableAutomaticSearch); + + if (filterBlockedIndexers) + { + return FilterBlockedIndexers(enabledIndexers).ToList(); + } + + return enabledIndexers.ToList(); + } + + public List InteractiveSearchEnabled(bool filterBlockedIndexers = true) + { + var enabledIndexers = GetAvailableProviders().Where(n => ((IndexerDefinition)n.Definition).EnableInteractiveSearch); if (filterBlockedIndexers) { diff --git a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs index bd16cc4d5..81e8bdd60 100644 --- a/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs +++ b/src/NzbDrone.Core/Indexers/Newznab/Newznab.cs @@ -66,7 +66,8 @@ namespace NzbDrone.Core.Indexers.Newznab return new IndexerDefinition { EnableRss = false, - EnableSearch = false, + EnableAutomaticSearch = false, + EnableInteractiveSearch = false, Name = name, Implementation = GetType().Name, Settings = settings, diff --git a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs index 6dc9591d1..597ee8451 100644 --- a/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs +++ b/src/NzbDrone.Core/Indexers/Torznab/Torznab.cs @@ -54,7 +54,8 @@ namespace NzbDrone.Core.Indexers.Torznab return new IndexerDefinition { EnableRss = false, - EnableSearch = false, + EnableAutomaticSearch = false, + EnableInteractiveSearch = false, Name = name, Implementation = GetType().Name, Settings = settings, diff --git a/src/NzbDrone.Core/Music/AlbumMonitoredService.cs b/src/NzbDrone.Core/Music/AlbumMonitoredService.cs index 6ffb30971..dea43f810 100644 --- a/src/NzbDrone.Core/Music/AlbumMonitoredService.cs +++ b/src/NzbDrone.Core/Music/AlbumMonitoredService.cs @@ -34,15 +34,7 @@ namespace NzbDrone.Core.Music var albums = _albumService.GetAlbumsByArtist(artist.Id); - if (monitoringOptions.Monitored) - { - ToggleAlbumsMonitoredState(albums, true); - } - - else - { - ToggleAlbumsMonitoredState(albums, false); - } + ToggleAlbumsMonitoredState(albums, monitoringOptions.Monitored); //TODO Add Other Options for Future/Exisitng/Missing Once we have a good way to check for Album Related Files. diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index a1670af00..d0f214d26 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -177,6 +177,7 @@ + diff --git a/src/NzbDrone.Integration.Test/IntegrationTest.cs b/src/NzbDrone.Integration.Test/IntegrationTest.cs index e886ae4d7..3141978d8 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTest.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTest.cs @@ -28,7 +28,8 @@ namespace NzbDrone.Integration.Test Indexers.Post(new Lidarr.Api.V1.Indexers.IndexerResource { EnableRss = false, - EnableSearch = false, + EnableInteractiveSearch = false, + EnableAutomaticSearch = false, ConfigContract = nameof(NewznabSettings), Implementation = nameof(Newznab), Name = "NewznabTest",