mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
New: Allow monitoring all albums for import list artist
This commit is contained in:
parent
8e777025cb
commit
23316329ed
7 changed files with 101 additions and 18 deletions
|
@ -5,7 +5,7 @@ namespace Lidarr.Api.V1.ImportLists
|
|||
public class ImportListResource : ProviderResource
|
||||
{
|
||||
public bool EnableAutomaticAdd { get; set; }
|
||||
public bool ShouldMonitor { get; set; }
|
||||
public ImportListMonitorType ShouldMonitor { get; set; }
|
||||
public string RootFolderPath { get; set; }
|
||||
public int QualityProfileId { get; set; }
|
||||
public int LanguageProfileId { get; set; }
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
|
||||
Mocker.GetMock<IImportListFactory>()
|
||||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Returns(new ImportListDefinition{ ShouldMonitor = true });
|
||||
.Returns(new ImportListDefinition{ ShouldMonitor = ImportListMonitorType.SpecificAlbum });
|
||||
|
||||
Mocker.GetMock<IFetchAndParseImportList>()
|
||||
.Setup(v => v.Fetch())
|
||||
|
@ -83,6 +83,13 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
});
|
||||
}
|
||||
|
||||
private void WithMonitorType(ImportListMonitorType monitor)
|
||||
{
|
||||
Mocker.GetMock<IImportListFactory>()
|
||||
.Setup(v => v.Get(It.IsAny<int>()))
|
||||
.Returns(new ImportListDefinition{ ShouldMonitor = monitor });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_if_artist_title_and_no_artist_id()
|
||||
{
|
||||
|
@ -152,17 +159,20 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t=>t.Count == 0)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_add_if_not_existing_artist()
|
||||
[TestCase(ImportListMonitorType.None, false)]
|
||||
[TestCase(ImportListMonitorType.SpecificAlbum, true)]
|
||||
[TestCase(ImportListMonitorType.EntireArtist, true)]
|
||||
public void should_add_if_not_existing_artist(ImportListMonitorType monitor, bool expectedArtistMonitored)
|
||||
{
|
||||
WithArtistId();
|
||||
WithAlbum();
|
||||
WithAlbumId();
|
||||
WithMonitorType(monitor);
|
||||
|
||||
Subject.Execute(new ImportListSyncCommand());
|
||||
|
||||
Mocker.GetMock<IAddArtistService>()
|
||||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t => t.Count == 1)));
|
||||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t => t.Count == 1 && t.First().Monitored == expectedArtistMonitored)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -180,11 +190,12 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_mark_album_for_monitor_if_album_id()
|
||||
public void should_mark_album_for_monitor_if_album_id_and_specific_monitor_selected()
|
||||
{
|
||||
WithArtistId();
|
||||
WithAlbum();
|
||||
WithAlbumId();
|
||||
WithMonitorType(ImportListMonitorType.SpecificAlbum);
|
||||
|
||||
Subject.Execute(new ImportListSyncCommand());
|
||||
|
||||
|
@ -192,6 +203,20 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t => t.Count == 1 && t.First().AddOptions.AlbumsToMonitor.Contains("09474d62-17dd-3a4f-98fb-04c65f38a479"))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_album_for_monitor_if_album_id_and_monitor_all_selected()
|
||||
{
|
||||
WithArtistId();
|
||||
WithAlbum();
|
||||
WithAlbumId();
|
||||
WithMonitorType(ImportListMonitorType.EntireArtist);
|
||||
|
||||
Subject.Execute(new ImportListSyncCommand());
|
||||
|
||||
Mocker.GetMock<IAddArtistService>()
|
||||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t => t.Count == 1 && !t.First().AddOptions.AlbumsToMonitor.Any())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_mark_album_for_monitor_if_no_album_id()
|
||||
{
|
||||
|
@ -202,6 +227,5 @@ namespace NzbDrone.Core.Test.ImportListTests
|
|||
Mocker.GetMock<IAddArtistService>()
|
||||
.Verify(v => v.AddArtists(It.Is<List<Artist>>(t => t.Count == 1 && t.First().AddOptions.AlbumsToMonitor.Count == 0)));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace NzbDrone.Core.ImportLists
|
|||
public class ImportListDefinition : ProviderDefinition
|
||||
{
|
||||
public bool EnableAutomaticAdd { get; set; }
|
||||
public bool ShouldMonitor { get; set; }
|
||||
public ImportListMonitorType ShouldMonitor { get; set; }
|
||||
public int ProfileId { get; set; }
|
||||
public int LanguageProfileId { get; set; }
|
||||
public int MetadataProfileId { get; set; }
|
||||
|
@ -15,4 +15,11 @@ namespace NzbDrone.Core.ImportLists
|
|||
|
||||
public ImportListStatus Status { get; set; }
|
||||
}
|
||||
|
||||
public enum ImportListMonitorType
|
||||
{
|
||||
None,
|
||||
SpecificAlbum,
|
||||
EntireArtist
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,13 +130,14 @@ namespace NzbDrone.Core.ImportLists
|
|||
// Append Artist if not already in DB or already on add list
|
||||
if (existingArtist == null && excludedArtist == null && artistsToAdd.All(s => s.Metadata.Value.ForeignArtistId != report.ArtistMusicBrainzId))
|
||||
{
|
||||
var monitored = importList.ShouldMonitor != ImportListMonitorType.None;
|
||||
artistsToAdd.Add(new Artist
|
||||
{
|
||||
Metadata = new ArtistMetadata {
|
||||
ForeignArtistId = report.ArtistMusicBrainzId,
|
||||
Name = report.Artist
|
||||
},
|
||||
Monitored = importList.ShouldMonitor,
|
||||
Monitored = monitored,
|
||||
RootFolderPath = importList.RootFolderPath,
|
||||
QualityProfileId = importList.ProfileId,
|
||||
LanguageProfileId = importList.LanguageProfileId,
|
||||
|
@ -144,15 +145,15 @@ namespace NzbDrone.Core.ImportLists
|
|||
Tags = importList.Tags,
|
||||
AlbumFolder = true,
|
||||
AddOptions = new AddArtistOptions {
|
||||
SearchForMissingAlbums = importList.ShouldMonitor,
|
||||
Monitored = importList.ShouldMonitor,
|
||||
Monitor = importList.ShouldMonitor ? MonitorTypes.All : MonitorTypes.None
|
||||
SearchForMissingAlbums = monitored,
|
||||
Monitored = monitored,
|
||||
Monitor = monitored ? MonitorTypes.All : MonitorTypes.None
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add Album so we know what to monitor
|
||||
if (report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace() && artistsToAdd.Any(s => s.Metadata.Value.ForeignArtistId == report.ArtistMusicBrainzId) && importList.ShouldMonitor)
|
||||
if (report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace() && artistsToAdd.Any(s => s.Metadata.Value.ForeignArtistId == report.ArtistMusicBrainzId) && importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum)
|
||||
{
|
||||
artistsToAdd.Find(s => s.Metadata.Value.ForeignArtistId == report.ArtistMusicBrainzId).AddOptions.AlbumsToMonitor.Add(report.AlbumMusicBrainzId);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue