From 2f796d611b6434bd866c9768c05fbc38bab5541d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 24 May 2013 12:05:53 -0400 Subject: [PATCH] support tv backdrops from fanart --- MediaBrowser.Api/LibraryService.cs | 10 +- .../Providers/FanartBaseProvider.cs | 10 - .../Providers/Movies/FanArtMovieProvider.cs | 176 ++++++++---------- .../Providers/Movies/TmdbPersonProvider.cs | 21 +-- .../Providers/TV/FanArtTVProvider.cs | 147 +++++++++------ .../Providers/TV/RemoteSeasonProvider.cs | 1 - .../Providers/TV/TvdbSeriesImageProvider.cs | 5 +- MediaBrowser.WebDashboard/ApiClient.js | 2 +- MediaBrowser.WebDashboard/packages.config | 2 +- 9 files changed, 179 insertions(+), 195 deletions(-) diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index bcf359aa4b..e3b93c3407 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -428,17 +428,13 @@ namespace MediaBrowser.Api try { + await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false); + if (folder != null) { - await - folder.ValidateChildren(new Progress(), CancellationToken.None, request.Recursive, + await folder.ValidateChildren(new Progress(), CancellationToken.None, request.Recursive, request.Forced).ConfigureAwait(false); } - else - { - await - item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false); - } } catch (Exception ex) { diff --git a/MediaBrowser.Controller/Providers/FanartBaseProvider.cs b/MediaBrowser.Controller/Providers/FanartBaseProvider.cs index 9873f0f2cb..c1249adee4 100644 --- a/MediaBrowser.Controller/Providers/FanartBaseProvider.cs +++ b/MediaBrowser.Controller/Providers/FanartBaseProvider.cs @@ -1,25 +1,15 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Model.Logging; -using System; using System.Collections.Generic; using System.Threading; namespace MediaBrowser.Controller.Providers { - class FanArtProviderException : ApplicationException - { - public FanArtProviderException(string msg) - : base(msg) - { - } - - } /// /// Class FanartBaseProvider /// public abstract class FanartBaseProvider : BaseMetadataProvider { - protected static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3,3); /// diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs index 3d115f2b01..4254b8fd1f 100644 --- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Providers.Movies return "12"; } } - + /// /// The fan art base URL /// @@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Providers.Movies { return false; } - + if (!ConfigurationManager.Configuration.DownloadMovieImages.Art && !ConfigurationManager.Configuration.DownloadMovieImages.Logo && !ConfigurationManager.Configuration.DownloadMovieImages.Disc && @@ -168,7 +168,7 @@ namespace MediaBrowser.Controller.Providers.Movies } var status = ProviderRefreshStatus.Success; - + var movie = item; var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); @@ -192,128 +192,102 @@ namespace MediaBrowser.Controller.Providers.Movies var saveLocal = ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem; - if (doc.HasChildNodes) + string path; + var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; + + if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo)) { - string path; - var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - - var hasLogo = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(LogoFile) - : item.HasImage(ImageType.Logo); - - if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !hasLogo) + var node = + doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/movielogos/movielogo[@lang = \"" + language + "\"]/@url"); + if (node == null && language != "en") { - var node = - doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/movielogos/movielogo[@lang = \"" + language + "\"]/@url"); - if (node == null && language != "en") - { - //maybe just couldn't find language - try just first one - node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo/@url"); - } - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LogoFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + //maybe just couldn't find language - try just first one + node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo/@url"); } - cancellationToken.ThrowIfCancellationRequested(); - - var hasArt = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(ArtFile) - : item.HasImage(ImageType.Art); - - if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !hasArt) + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var node = - doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviearts/movieart[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviearts/movieart/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ArtFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LogoFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } - cancellationToken.ThrowIfCancellationRequested(); + } + cancellationToken.ThrowIfCancellationRequested(); - var hasDisc = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(DiscFile) - : item.HasImage(ImageType.Disc); - - if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !hasDisc) + if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art)) + { + var node = + doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviearts/movieart[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviearts/movieart/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DiscFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ArtFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } + } + cancellationToken.ThrowIfCancellationRequested(); - cancellationToken.ThrowIfCancellationRequested(); - - var hasBanner = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(BannerFile) - : item.HasImage(ImageType.Banner); - - if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !hasBanner) + if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc)) + { + var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BannerFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DiscFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } + } - cancellationToken.ThrowIfCancellationRequested(); + cancellationToken.ThrowIfCancellationRequested(); - var hasThumb = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(ThumbFile) - : item.HasImage(ImageType.Thumb); - - if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !hasThumb) + if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner)) + { + var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, ThumbFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BannerFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } + } - var hasBackdrop = item.LocationType == LocationType.FileSystem ? - item.ResolveArgs.ContainsMetaFileByName(BackdropFile) - : item.BackdropImagePaths.Count > 0; + cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && !hasBackdrop) + if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb)) + { + var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var nodes = doc.SelectNodes("//fanart/movie/moviebackgrounds//@url"); - if (nodes != null) + movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, ThumbFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + } + + if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops) + { + var nodes = doc.SelectNodes("//fanart/movie/moviebackgrounds//@url"); + + if (nodes != null) + { + var numBackdrops = item.BackdropImagePaths.Count; + + foreach (XmlNode node in nodes) { - var numBackdrops = 0; - item.BackdropImagePaths = new List(); - foreach (XmlNode node in nodes) + path = node.Value; + + if (!string.IsNullOrEmpty(path)) { - path = node.Value; - if (!string.IsNullOrEmpty(path)) - { - Logger.Debug("FanArtProvider getting Backdrop for " + item.Name); - item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - numBackdrops++; - if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break; - } - } + item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + + numBackdrops++; + if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) break; + } } } - } data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb)); diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs index b909986437..ced342a9c8 100644 --- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs @@ -265,7 +265,7 @@ namespace MediaBrowser.Controller.Providers.Movies //still nothing - just get first one profile = searchResult.profiles[0]; } - if (profile != null) + if (profile != null && !person.HasImage(ImageType.Primary)) { var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); @@ -299,20 +299,19 @@ namespace MediaBrowser.Controller.Providers.Movies //download and save locally (if not already there) var localPath = Path.Combine(item.MetaLocation, targetName); - if (!item.ResolveArgs.ContainsMetaFileByName(targetName)) + + using (var sourceStream = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions { - using (var sourceStream = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions - { - Url = source, - CancellationToken = cancellationToken + Url = source, + CancellationToken = cancellationToken - }).ConfigureAwait(false)) - { - await ProviderManager.SaveToLibraryFilesystem(item, localPath, sourceStream, cancellationToken).ConfigureAwait(false); + }).ConfigureAwait(false)) + { + await ProviderManager.SaveToLibraryFilesystem(item, localPath, sourceStream, cancellationToken).ConfigureAwait(false); - Logger.Debug("TmdbPersonProvider downloaded and saved image for {0}", item.Name); - } + Logger.Debug("TmdbPersonProvider downloaded and saved image for {0}", item.Name); } + return localPath; } diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs index 534566c84d..2a8067f6a5 100644 --- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs @@ -1,11 +1,11 @@ -using MediaBrowser.Common.Extensions; +using System.Globalization; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Net; using System; using System.Threading; using System.Threading.Tasks; @@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.Providers.TV { return false; } - + if (!ConfigurationManager.Configuration.DownloadSeriesImages.Art && !ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && @@ -79,6 +79,8 @@ namespace MediaBrowser.Controller.Providers.TV { return string.IsNullOrEmpty(id) ? Guid.Empty : id.GetMD5(); } + + protected readonly CultureInfo UsCulture = new CultureInfo("en-US"); public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { @@ -92,7 +94,7 @@ namespace MediaBrowser.Controller.Providers.TV data = new BaseProviderInfo(); item.ProviderData[Id] = data; } - + var series = (Series)item; string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); @@ -113,68 +115,91 @@ namespace MediaBrowser.Controller.Providers.TV cancellationToken.ThrowIfCancellationRequested(); - if (doc.HasChildNodes) + string path; + var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear"; + if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.HasImage(ImageType.Logo)) { - string path; - var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear"; - if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LogoFile)) + var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo/@url") ?? + doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) { - var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo/@url") ?? - doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name); - series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LogoFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } - } - - cancellationToken.ThrowIfCancellationRequested(); - - hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ArtFile)) - { - var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart/@url") ?? - doc.SelectSingleNode("//fanart/series/cleararts/clearart/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - Logger.Debug("FanArtProvider getting ClearArt for " + series.Name); - series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ArtFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } - } - - cancellationToken.ThrowIfCancellationRequested(); - - if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.ResolveArgs.ContainsMetaFileByName(ThumbFile)) - { - var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name); - series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, ThumbFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } - } - - if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.ResolveArgs.ContainsMetaFileByName(BannerFile)) - { - var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ?? - doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url"); - path = node != null ? node.Value : null; - if (!string.IsNullOrEmpty(path)) - { - Logger.Debug("FanArtProvider getting banner for " + series.Name); - series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BannerFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); - } + Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name); + series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LogoFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); } } + cancellationToken.ThrowIfCancellationRequested(); + + hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; + if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.HasImage(ImageType.Art)) + { + var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart/@url") ?? + doc.SelectSingleNode("//fanart/series/cleararts/clearart/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) + { + Logger.Debug("FanArtProvider getting ClearArt for " + series.Name); + series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ArtFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + } + + cancellationToken.ThrowIfCancellationRequested(); + + if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.HasImage(ImageType.Thumb)) + { + var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) + { + Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name); + series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, ThumbFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + } + + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.HasImage(ImageType.Banner)) + { + var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ?? + doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url"); + path = node != null ? node.Value : null; + if (!string.IsNullOrEmpty(path)) + { + Logger.Debug("FanArtProvider getting banner for " + series.Name); + series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BannerFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + } + } + + if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops) + { + var nodes = doc.SelectNodes("//fanart/series/showbackgrounds//@url"); + + if (nodes != null) + { + var numBackdrops = item.BackdropImagePaths.Count; + + foreach (XmlNode node in nodes) + { + path = node.Value; + + if (!string.IsNullOrEmpty(path)) + { + item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); + + numBackdrops++; + + if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) break; + } + } + + } + } + + data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tvdb)); SetLastRefreshed(series, DateTime.UtcNow, status); diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs index 9b0bf824ab..585c24b141 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs @@ -7,7 +7,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; -using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Controller/Providers/TV/TvdbSeriesImageProvider.cs b/MediaBrowser.Controller/Providers/TV/TvdbSeriesImageProvider.cs index 423e90efb3..c183075d68 100644 --- a/MediaBrowser.Controller/Providers/TV/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/TvdbSeriesImageProvider.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -8,6 +7,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; +using System.Globalization; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -257,6 +257,7 @@ namespace MediaBrowser.Controller.Providers.TV if (series.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops) { var bdNo = series.BackdropImagePaths.Count; + var xmlNodeList = images.SelectNodes("//Banner[BannerType='fanart']"); if (xmlNodeList != null) { diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index 62204c2b11..d33731b70c 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -388,7 +388,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { var url = self.getUrl("Items/" + itemId + "/Refresh", { - force: force || false, + forced: force || false, recursive: recursive || false }); diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index ae67867dd1..de8912c0ee 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file