diff --git a/MediaBrowser.Model/Entities/MetadataFields.cs b/MediaBrowser.Model/Entities/MetadataFields.cs index 9f72d812e7..a99fd0fe01 100644 --- a/MediaBrowser.Model/Entities/MetadataFields.cs +++ b/MediaBrowser.Model/Entities/MetadataFields.cs @@ -45,6 +45,14 @@ namespace MediaBrowser.Model.Entities /// /// The images /// - Images + Images, + /// + /// The backdrops + /// + Backdrops, + /// + /// The screenshots + /// + Screenshots } } diff --git a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs index 9084316c9e..c512eb8897 100644 --- a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs @@ -168,11 +168,8 @@ namespace MediaBrowser.Providers.Movies /// Task{System.Boolean}. public override async Task FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) { - if (!item.LockedFields.Contains(MetadataFields.Images)) - { - var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false); - await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); - } + var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbImageProvider.ProviderName).ConfigureAwait(false); + await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow, providerInfo); return true; @@ -194,7 +191,7 @@ namespace MediaBrowser.Providers.Movies .ToList(); // poster - if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary)) + if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images)) { var poster = eligiblePosters[0]; @@ -220,7 +217,10 @@ namespace MediaBrowser.Providers.Movies var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops; // backdrops - only download if earlier providers didn't find any (fanart) - if (eligibleBackdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit) + if (eligibleBackdrops.Count > 0 && + ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && + item.BackdropImagePaths.Count < backdropLimit && + !item.LockedFields.Contains(MetadataFields.Backdrops)) { for (var i = 0; i < eligibleBackdrops.Count; i++) { diff --git a/MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs b/MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs index 03fd8d0a37..f6c908a7c5 100644 --- a/MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbPersonImageProvider.cs @@ -163,11 +163,8 @@ namespace MediaBrowser.Providers.Movies /// Task{System.Boolean}. public override async Task FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken) { - if (!item.LockedFields.Contains(MetadataFields.Images)) - { - var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false); - await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); - } + var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualMovieDbPersonImageProvider.ProviderName).ConfigureAwait(false); + await ProcessImages(item, images.ToList(), cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow, providerInfo); return true; @@ -189,7 +186,7 @@ namespace MediaBrowser.Providers.Movies .ToList(); // poster - if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary)) + if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedFields.Contains(MetadataFields.Images)) { var poster = eligiblePosters[0]; diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index c5da218bb9..454d56daf4 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -212,12 +212,11 @@ namespace MediaBrowser.Providers.Music await DownloadArtistXml(artistDataPath, musicBrainzId, cancellationToken).ConfigureAwait(false); } - if (!item.LockedFields.Contains(MetadataFields.Images) && - (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art || - ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops || - ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner || - ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo || - ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art || + ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops || + ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner || + ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo || + ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary) { var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartArtistProvider.ProviderName).ConfigureAwait(false); await FetchFromXml(item, images.ToList(), cancellationToken).ConfigureAwait(false); @@ -268,46 +267,52 @@ namespace MediaBrowser.Providers.Music /// Task. private async Task FetchFromXml(BaseItem item, List images , CancellationToken cancellationToken) { - cancellationToken.ThrowIfCancellationRequested(); - - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary)) + if (!item.LockedFields.Contains(MetadataFields.Images)) { - await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary)) + { + await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo)) - { - await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo)) + { + await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art)) - { - await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art)) + { + await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner)) - { - await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner)) + { + await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); + } + } - var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops; - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && - item.BackdropImagePaths.Count < backdropLimit) + if (!item.LockedFields.Contains(MetadataFields.Backdrops)) { - foreach (var image in images.Where(i => i.Type == ImageType.Backdrop)) + cancellationToken.ThrowIfCancellationRequested(); + + var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops; + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && + item.BackdropImagePaths.Count < backdropLimit) { - await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Backdrop, null, cancellationToken) - .ConfigureAwait(false); + foreach (var image in images.Where(i => i.Type == ImageType.Backdrop)) + { + await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Backdrop, null, cancellationToken) + .ConfigureAwait(false); - if (item.BackdropImagePaths.Count >= backdropLimit) break; + if (item.BackdropImagePaths.Count >= backdropLimit) break; + } } } } diff --git a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs index b1602bfd36..50ce72a89d 100644 --- a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs @@ -101,14 +101,11 @@ namespace MediaBrowser.Providers.TV { cancellationToken.ThrowIfCancellationRequested(); - var season = (Season)item; + var season = (Season) item; - if (!item.LockedFields.Contains(MetadataFields.Images)) - { - // Process images - var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartSeasonImageProvider.ProviderName).ConfigureAwait(false); - await FetchImages(season, images.ToList(), cancellationToken).ConfigureAwait(false); - } + // Process images + var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualFanartSeasonImageProvider.ProviderName).ConfigureAwait(false); + await FetchImages(season, images.ToList(), cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow, providerInfo); return true; @@ -123,7 +120,7 @@ namespace MediaBrowser.Providers.TV /// Task. private async Task FetchImages(Season season, List images, CancellationToken cancellationToken) { - if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb)) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb) && !season.LockedFields.Contains(MetadataFields.Images)) { await SaveImage(season, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false); } diff --git a/MediaBrowser.Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Providers/TV/FanArtTVProvider.cs index 8bb56dabd4..d939951fb8 100644 --- a/MediaBrowser.Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Providers/TV/FanArtTVProvider.cs @@ -167,7 +167,7 @@ namespace MediaBrowser.Providers.TV var seriesId = item.GetProviderId(MetadataProviders.Tvdb); - if (!string.IsNullOrEmpty(seriesId) && !item.LockedFields.Contains(MetadataFields.Images)) + if (!string.IsNullOrEmpty(seriesId)) { var xmlPath = GetFanartXmlPath(seriesId); @@ -196,56 +196,61 @@ namespace MediaBrowser.Providers.TV /// Task. private async Task FetchFromXml(BaseItem item, List images, CancellationToken cancellationToken) { - cancellationToken.ThrowIfCancellationRequested(); - - if (ConfigurationManager.Configuration.DownloadSeriesImages.Primary && !item.HasImage(ImageType.Primary)) + if (!item.LockedFields.Contains(MetadataFields.Images)) { - await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadSeriesImages.Primary && !item.HasImage(ImageType.Primary)) + { + await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo)) - { - await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo)) + { + await SaveImage(item, images, ImageType.Logo, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art)) - { - await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art)) + { + await SaveImage(item, images, ImageType.Art, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb)) - { - await SaveImage(item, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb)) + { + await SaveImage(item, images, ImageType.Thumb, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner)) - { - await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); - } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner)) + { + await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); + } + } - var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops; - if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && - item.BackdropImagePaths.Count < backdropLimit) + if (!item.LockedFields.Contains(MetadataFields.Backdrops)) { - foreach (var image in images.Where(i => i.Type == ImageType.Backdrop)) + cancellationToken.ThrowIfCancellationRequested(); + + var backdropLimit = ConfigurationManager.Configuration.MaxBackdrops; + if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && + item.BackdropImagePaths.Count < backdropLimit) { - await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Backdrop, null, cancellationToken) - .ConfigureAwait(false); + foreach (var image in images.Where(i => i.Type == ImageType.Backdrop)) + { + await _providerManager.SaveImage(item, image.Url, FanArtResourcePool, ImageType.Backdrop, null, cancellationToken) + .ConfigureAwait(false); - if (item.BackdropImagePaths.Count >= backdropLimit) break; + if (item.BackdropImagePaths.Count >= backdropLimit) break; + } } } - } private async Task SaveImage(BaseItem item, List images, ImageType type, CancellationToken cancellationToken) diff --git a/MediaBrowser.Providers/TV/TvdbSeasonProvider.cs b/MediaBrowser.Providers/TV/TvdbSeasonProvider.cs index 76e70d772a..17ed6b5a24 100644 --- a/MediaBrowser.Providers/TV/TvdbSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeasonProvider.cs @@ -147,14 +147,11 @@ namespace MediaBrowser.Providers.TV { cancellationToken.ThrowIfCancellationRequested(); - if (!item.LockedFields.Contains(MetadataFields.Images)) - { - var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeasonImageProvider.ProviderName).ConfigureAwait(false); + var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeasonImageProvider.ProviderName).ConfigureAwait(false); - const int backdropLimit = 1; + const int backdropLimit = 1; - await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); - } + await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow, providerInfo); return true; @@ -162,17 +159,20 @@ namespace MediaBrowser.Providers.TV private async Task DownloadImages(BaseItem item, List images, int backdropLimit, CancellationToken cancellationToken) { - if (!item.HasImage(ImageType.Primary)) + if (!item.LockedFields.Contains(MetadataFields.Images)) { - await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); - } + if (!item.HasImage(ImageType.Primary)) + { + await SaveImage(item, images, ImageType.Primary, cancellationToken).ConfigureAwait(false); + } - if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && !item.HasImage(ImageType.Banner)) - { - await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); + if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && !item.HasImage(ImageType.Banner)) + { + await SaveImage(item, images, ImageType.Banner, cancellationToken).ConfigureAwait(false); + } } - if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit && !item.LockedFields.Contains(MetadataFields.Backdrops)) { foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop)) { diff --git a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs index 752ce0280b..9220b8fa06 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs @@ -143,7 +143,7 @@ namespace MediaBrowser.Providers.TV } return base.NeedsRefreshInternal(item, providerInfo); } - + /// /// Fetches metadata and returns true or false indicating if any work that requires persistence was done /// @@ -155,14 +155,11 @@ namespace MediaBrowser.Providers.TV { cancellationToken.ThrowIfCancellationRequested(); - if (!item.LockedFields.Contains(MetadataFields.Images)) - { - var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeriesImageProvider.ProviderName).ConfigureAwait(false); + var images = await _providerManager.GetAvailableRemoteImages(item, cancellationToken, ManualTvdbSeriesImageProvider.ProviderName).ConfigureAwait(false); - const int backdropLimit = 1; + const int backdropLimit = 1; - await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); - } + await DownloadImages(item, images.ToList(), backdropLimit, cancellationToken).ConfigureAwait(false); SetLastRefreshed(item, DateTime.UtcNow, providerInfo); return true; @@ -170,29 +167,32 @@ namespace MediaBrowser.Providers.TV private async Task DownloadImages(BaseItem item, List images, int backdropLimit, CancellationToken cancellationToken) { - if (!item.HasImage(ImageType.Primary)) + if (!item.LockedFields.Contains(MetadataFields.Images)) { - var image = images.FirstOrDefault(i => i.Type == ImageType.Primary); - - if (image != null) + if (!item.HasImage(ImageType.Primary)) { - await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken) - .ConfigureAwait(false); - } - } + var image = images.FirstOrDefault(i => i.Type == ImageType.Primary); - if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner)) - { - var image = images.FirstOrDefault(i => i.Type == ImageType.Banner); + if (image != null) + { + await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken) + .ConfigureAwait(false); + } + } - if (image != null) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner)) { - await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Banner, null, cancellationToken) - .ConfigureAwait(false); + var image = images.FirstOrDefault(i => i.Type == ImageType.Banner); + + if (image != null) + { + await _providerManager.SaveImage(item, image.Url, TvdbSeriesProvider.Current.TvDbResourcePool, ImageType.Banner, null, cancellationToken) + .ConfigureAwait(false); + } } } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops && item.BackdropImagePaths.Count < backdropLimit && !item.LockedFields.Contains(MetadataFields.Backdrops)) { foreach (var backdrop in images.Where(i => i.Type == ImageType.Backdrop && (!i.Width.HasValue ||