mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Allow changing monitoring the artist without the albums
This commit is contained in:
parent
690b2c72c8
commit
661338f5b1
1 changed files with 70 additions and 62 deletions
|
@ -25,18 +25,24 @@ namespace NzbDrone.Core.Music
|
|||
|
||||
public void SetAlbumMonitoredStatus(Artist artist, MonitoringOptions monitoringOptions)
|
||||
{
|
||||
if (monitoringOptions != null)
|
||||
// Update the artist without changing the albums
|
||||
if (monitoringOptions == null)
|
||||
{
|
||||
_artistService.UpdateArtist(artist);
|
||||
return;
|
||||
}
|
||||
|
||||
var monitoredAlbums = monitoringOptions.AlbumsToMonitor;
|
||||
|
||||
if (monitoringOptions.Monitor == MonitorTypes.Unknown && monitoredAlbums is not { Count: not 0 })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Debug("[{0}] Setting album monitored status.", artist.Name);
|
||||
|
||||
var albums = _albumService.GetAlbumsByArtist(artist.Id);
|
||||
|
||||
var albumsWithFiles = _albumService.GetArtistAlbumsWithFiles(artist);
|
||||
|
||||
var albumsWithoutFiles = albums.Where(c => !albumsWithFiles.Select(e => e.Id).Contains(c.Id) && c.ReleaseDate <= DateTime.UtcNow).ToList();
|
||||
|
||||
var monitoredAlbums = monitoringOptions.AlbumsToMonitor;
|
||||
|
||||
// If specific albums are passed use those instead of the monitoring options.
|
||||
if (monitoredAlbums.Any())
|
||||
{
|
||||
|
@ -45,9 +51,13 @@ namespace NzbDrone.Core.Music
|
|||
}
|
||||
else
|
||||
{
|
||||
var albumsWithFiles = _albumService.GetArtistAlbumsWithFiles(artist);
|
||||
var albumsWithoutFiles = albums.Where(c => !albumsWithFiles.Select(e => e.Id).Contains(c.Id) && c.ReleaseDate <= DateTime.UtcNow).ToList();
|
||||
|
||||
switch (monitoringOptions.Monitor)
|
||||
{
|
||||
case MonitorTypes.All:
|
||||
_logger.Debug("Monitoring all albums");
|
||||
ToggleAlbumsMonitoredState(albums, true);
|
||||
break;
|
||||
case MonitorTypes.Future:
|
||||
|
@ -56,9 +66,6 @@ namespace NzbDrone.Core.Music
|
|||
_logger.Debug("Unmonitoring Albums without Files");
|
||||
ToggleAlbumsMonitoredState(albums.Where(e => albumsWithoutFiles.Select(c => c.Id).Contains(e.Id)), false);
|
||||
break;
|
||||
case MonitorTypes.None:
|
||||
ToggleAlbumsMonitoredState(albums, false);
|
||||
break;
|
||||
case MonitorTypes.Missing:
|
||||
_logger.Debug("Unmonitoring Albums with Files");
|
||||
ToggleAlbumsMonitoredState(albums.Where(e => albumsWithFiles.Select(c => c.Id).Contains(e.Id)), false);
|
||||
|
@ -72,15 +79,18 @@ namespace NzbDrone.Core.Music
|
|||
ToggleAlbumsMonitoredState(albums.Where(e => albumsWithoutFiles.Select(c => c.Id).Contains(e.Id)), false);
|
||||
break;
|
||||
case MonitorTypes.Latest:
|
||||
_logger.Debug("Monitoring latest album");
|
||||
ToggleAlbumsMonitoredState(albums, false);
|
||||
ToggleAlbumsMonitoredState(albums.OrderByDescending(e => e.ReleaseDate).Take(1), true);
|
||||
break;
|
||||
case MonitorTypes.First:
|
||||
_logger.Debug("Monitoring first album");
|
||||
ToggleAlbumsMonitoredState(albums, false);
|
||||
ToggleAlbumsMonitoredState(albums.OrderBy(e => e.ReleaseDate).Take(1), true);
|
||||
break;
|
||||
case MonitorTypes.Unknown:
|
||||
// Ignoring, it's the default value
|
||||
case MonitorTypes.None:
|
||||
_logger.Debug("Unmonitoring all albums");
|
||||
ToggleAlbumsMonitoredState(albums, false);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
@ -88,8 +98,6 @@ namespace NzbDrone.Core.Music
|
|||
}
|
||||
|
||||
_albumService.UpdateMany(albums);
|
||||
}
|
||||
|
||||
_artistService.UpdateArtist(artist);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue