From b7a6a1d5740e81e7c3da68c3cc8bbe7d112396b0 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Mon, 4 Mar 2013 11:09:15 -0500 Subject: [PATCH] Refactor art download options (still need config changes) --- .../Providers/Movies/FanArtMovieProvider.cs | 16 ++-- .../Providers/Music/FanArtArtistProvider.cs | 16 ++-- .../Providers/TV/FanArtTVProvider.cs | 12 +-- .../Providers/TV/RemoteSeasonProvider.cs | 4 +- .../Providers/TV/RemoteSeriesProvider.cs | 2 +- .../Configuration/ServerConfiguration.cs | 84 ++++--------------- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + 7 files changed, 43 insertions(+), 92 deletions(-) diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs index d307fe099..9c71642e9 100644 --- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs @@ -91,9 +91,9 @@ namespace MediaBrowser.Controller.Providers.Movies var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE); var discExists = item.ResolveArgs.ContainsMetaFileByName(DISC_FILE); - return (!artExists && ConfigurationManager.Configuration.DownloadMovieArt) - || (!logoExists && ConfigurationManager.Configuration.DownloadMovieLogo) - || (!discExists && ConfigurationManager.Configuration.DownloadMovieDisc); + return (!artExists && ConfigurationManager.Configuration.DownloadMovieImages.Art) + || (!logoExists && ConfigurationManager.Configuration.DownloadMovieImages.Logo) + || (!discExists && ConfigurationManager.Configuration.DownloadMovieImages.Disc); } /// @@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.Providers.Movies { string path; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadMovieLogo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) { var node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ?? @@ -160,7 +160,7 @@ namespace MediaBrowser.Controller.Providers.Movies } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieArt && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) { var node = doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ?? @@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.Movies } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieDisc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE)) { var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url"); @@ -210,7 +210,7 @@ namespace MediaBrowser.Controller.Providers.Movies cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieBanner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE)) { var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url"); @@ -234,7 +234,7 @@ namespace MediaBrowser.Controller.Providers.Movies cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieThumb && !item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE)) { var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url"); diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs index d4585d58a..9f0dedf4d 100644 --- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs @@ -66,9 +66,9 @@ namespace MediaBrowser.Controller.Providers.Music var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE); var discExists = item.ResolveArgs.ContainsMetaFileByName(DISC_FILE); - return (!artExists && ConfigurationManager.Configuration.DownloadMovieArt) - || (!logoExists && ConfigurationManager.Configuration.DownloadMovieLogo) - || (!discExists && ConfigurationManager.Configuration.DownloadMovieDisc); + return (!artExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Art) + || (!logoExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo) + || (!discExists && ConfigurationManager.Configuration.DownloadMusicArtistImages.Disc); } /// @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Providers.Music { string path; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadMovieLogo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) { var node = doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ?? @@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Providers.Music } cancellationToken.ThrowIfCancellationRequested(); - if (!item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && !item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE)) { var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url"); if (nodes != null) @@ -163,7 +163,7 @@ namespace MediaBrowser.Controller.Providers.Music cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieArt && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) { var node = doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ?? @@ -187,7 +187,7 @@ namespace MediaBrowser.Controller.Providers.Music } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieBanner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE)) { var node = doc.SelectSingleNode("//fanart/music/musicbanners/"+hd+"musicbanner/@url") ?? doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url"); @@ -212,7 +212,7 @@ namespace MediaBrowser.Controller.Providers.Music cancellationToken.ThrowIfCancellationRequested(); // Artist thumbs are actually primary images (they are square/portrait) - if (!item.ResolveArgs.ContainsMetaFileByName(PRIMARY_FILE)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PRIMARY_FILE)) { var node = doc.SelectSingleNode("//fanart/music/artistthumbs/artistthumb/@url"); path = node != null ? node.Value : null; diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs index d89545a8d..5dcead7b1 100644 --- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs @@ -48,9 +48,9 @@ namespace MediaBrowser.Controller.Providers.TV var thumbExists = item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE); - return (!artExists && ConfigurationManager.Configuration.DownloadTVArt) - || (!logoExists && ConfigurationManager.Configuration.DownloadTVLogo) - || (!thumbExists && ConfigurationManager.Configuration.DownloadTVThumb); + return (!artExists && ConfigurationManager.Configuration.DownloadSeriesImages.Art) + || (!logoExists && ConfigurationManager.Configuration.DownloadSeriesImages.Logo) + || (!thumbExists && ConfigurationManager.Configuration.DownloadSeriesImages.Thumb); } protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken) @@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Providers.TV if (doc.HasChildNodes) { string path; - if (ConfigurationManager.Configuration.DownloadTVLogo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) { var node = doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo/@url"); @@ -104,7 +104,7 @@ namespace MediaBrowser.Controller.Providers.TV cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadTVArt && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE)) { var node = doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/cleararts/clearart/@url"); @@ -128,7 +128,7 @@ namespace MediaBrowser.Controller.Providers.TV cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadTVThumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE)) { var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url"); diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs index 71741d225..03d7d3353 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadTVSeasonBanner && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("banner"))) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("banner"))) { var n = images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='seasonwide'][Season='" + seasonNumber + "']"); if (n != null) @@ -218,7 +218,7 @@ namespace MediaBrowser.Controller.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadTVSeasonBackdrops && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("backdrop"))) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && (ConfigurationManager.Configuration.RefreshItemImages || !season.HasLocalImage("backdrop"))) { var n = images.SelectSingleNode("//Banner[BannerType='fanart'][Season='" + seasonNumber + "']"); if (n != null) diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs index 1d4063cdd..efb158b1e 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs @@ -379,7 +379,7 @@ namespace MediaBrowser.Controller.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadTVBanner && (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage("banner"))) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage("banner"))) { var n = images.SelectSingleNode("//Banner[BannerType='series']"); if (n != null) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 71f368397..5930920fb 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Updates; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Updates; using MediaBrowser.Model.Weather; using ProtoBuf; using System; @@ -96,88 +97,34 @@ namespace MediaBrowser.Model.Configuration public int MaxBackdrops { get; set; } /// - /// Gets or sets a value indicating whether [download movie art]. + /// Options for specific art to download for movies. /// - /// true if [download movie art]; otherwise, false. [ProtoMember(40)] - public bool DownloadMovieArt { get; set; } + public ImageDownloadOptions DownloadMovieImages { get; set; } /// - /// Gets or sets a value indicating whether [download movie logo]. + /// Options for specific art to download for Series. /// - /// true if [download movie logo]; otherwise, false. [ProtoMember(41)] - public bool DownloadMovieLogo { get; set; } + public ImageDownloadOptions DownloadSeriesImages { get; set; } /// - /// Gets or sets a value indicating whether [download movie disc]. + /// Options for specific art to download for Seasons. /// - /// true if [download movie disc]; otherwise, false. [ProtoMember(42)] - public bool DownloadMovieDisc { get; set; } + public ImageDownloadOptions DownloadSeasonImages { get; set; } /// - /// Gets or sets a value indicating whether [download TV art]. + /// Options for specific art to download for MusicArtists. /// - /// true if [download TV art]; otherwise, false. [ProtoMember(43)] - public bool DownloadTVArt { get; set; } + public ImageDownloadOptions DownloadMusicArtistImages { get; set; } /// - /// Gets or sets a value indicating whether [download TV logo]. + /// Options for specific art to download for MusicAlbums. /// - /// true if [download TV logo]; otherwise, false. [ProtoMember(44)] - public bool DownloadTVLogo { get; set; } - - /// - /// Gets or sets a value indicating whether [download TV thumb]. - /// - /// true if [download TV thumb]; otherwise, false. - [ProtoMember(45)] - public bool DownloadTVThumb { get; set; } - - /// - /// Gets or sets a value indicating whether [download movie banner]. - /// - /// true if [download movie banner]; otherwise, false. - [ProtoMember(46)] - public bool DownloadMovieBanner { get; set; } - - /// - /// Gets or sets a value indicating whether [download movie thumb]. - /// - /// true if [download movie thumb]; otherwise, false. - [ProtoMember(47)] - public bool DownloadMovieThumb { get; set; } - - /// - /// Gets or sets a value indicating whether [download TV banner]. - /// - /// true if [download TV banner]; otherwise, false. - [ProtoMember(48)] - public bool DownloadTVBanner { get; set; } - - /// - /// Gets or sets a value indicating whether [download TV season banner]. - /// - /// true if [download TV season banner]; otherwise, false. - [ProtoMember(49)] - public bool DownloadTVSeasonBanner { get; set; } - - /// - /// Gets or sets a value indicating whether [download TV season thumb]. - /// - /// true if [download TV season thumb]; otherwise, false. - [ProtoMember(50)] - public bool DownloadTVSeasonThumb { get; set; } - - /// - /// Gets or sets a value indicating whether [download TV season backdrops]. - /// - /// true if [download TV season banner]; otherwise, false. - [ProtoMember(51)] - public bool DownloadTVSeasonBackdrops { get; set; } + public ImageDownloadOptions DownloadMusicAlbumImages { get; set; } /// /// Gets or sets a value indicating whether [download TV season backdrops]. @@ -330,8 +277,11 @@ namespace MediaBrowser.Model.Configuration TmdbFetchedProfileSize = "w185"; //w185 w45 h632 or original TmdbFetchedPosterSize = "w500"; //w500, w342, w185 or original TmdbFetchedBackdropSize = "w1280"; //w1280, w780 or original - DownloadTVSeasonBanner = true; - DownloadTVBanner = true; + DownloadMovieImages = new ImageDownloadOptions {Backdrops = true, Primary = true}; + DownloadSeriesImages = new ImageDownloadOptions {Backdrops = true, Primary = true, Banner = true, Logo = true}; + DownloadSeasonImages = new ImageDownloadOptions {Backdrops = false, Primary = true, Banner = true}; + DownloadMusicArtistImages = new ImageDownloadOptions {Backdrops = true, Primary = true, Banner = true}; + DownloadMusicAlbumImages = new ImageDownloadOptions {Backdrops = true, Primary = false}; DownloadHDFanArt = true; MaxBackdrops = 4; diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index f291e12c9..0d0e20f81 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -49,6 +49,7 @@ +