|
@@ -1,5 +1,4 @@
|
|
-using MediaBrowser.Common.Extensions;
|
|
|
|
-using MediaBrowser.Common.Net;
|
|
|
|
|
|
+using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
@@ -57,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|
FanArtResourcePool.Dispose();
|
|
FanArtResourcePool.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// The fan art base URL
|
|
/// The fan art base URL
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -74,22 +73,26 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// Shoulds the fetch.
|
|
|
|
|
|
+ /// Needses the refresh internal.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="item">The item.</param>
|
|
/// <param name="item">The item.</param>
|
|
/// <param name="providerInfo">The provider info.</param>
|
|
/// <param name="providerInfo">The provider info.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
|
- protected override bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
|
|
|
|
|
|
+ protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
|
{
|
|
{
|
|
- var baseItem = item;
|
|
|
|
- if (item.Path == null || item.DontFetchMeta || string.IsNullOrEmpty(baseItem.GetProviderId(MetadataProviders.Tmdb))) return false; //nothing to do
|
|
|
|
- var artExists = item.ResolveArgs.ContainsMetaFileByName(ART_FILE);
|
|
|
|
- var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE);
|
|
|
|
- var discExists = item.ResolveArgs.ContainsMetaFileByName(DISC_FILE);
|
|
|
|
|
|
+ if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
- return (!artExists && ConfigurationManager.Configuration.DownloadMovieImages.Art)
|
|
|
|
- || (!logoExists && ConfigurationManager.Configuration.DownloadMovieImages.Logo)
|
|
|
|
- || (!discExists && ConfigurationManager.Configuration.DownloadMovieImages.Disc);
|
|
|
|
|
|
+ if (!ConfigurationManager.Configuration.DownloadMovieImages.Art &&
|
|
|
|
+ !ConfigurationManager.Configuration.DownloadMovieImages.Logo &&
|
|
|
|
+ !ConfigurationManager.Configuration.DownloadMovieImages.Disc)
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return base.NeedsRefreshInternal(item, providerInfo);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -105,157 +108,148 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|
|
|
|
|
var movie = item;
|
|
var movie = item;
|
|
|
|
|
|
- BaseProviderInfo providerData;
|
|
|
|
|
|
+ var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
|
|
|
+ var url = string.Format(FanArtBaseUrl, APIKey, movie.GetProviderId(MetadataProviders.Tmdb));
|
|
|
|
+ var doc = new XmlDocument();
|
|
|
|
|
|
- if (!item.ProviderData.TryGetValue(Id, out providerData))
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- providerData = new BaseProviderInfo();
|
|
|
|
|
|
+ using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
|
|
|
|
+ {
|
|
|
|
+ doc.Load(xml);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (ShouldFetch(movie, providerData))
|
|
|
|
|
|
+ catch (HttpException)
|
|
{
|
|
{
|
|
- var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
|
|
|
- var url = string.Format(FanArtBaseUrl, APIKey, movie.GetProviderId(MetadataProviders.Tmdb));
|
|
|
|
- var doc = new XmlDocument();
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- try
|
|
|
|
|
|
+ if (doc.HasChildNodes)
|
|
|
|
+ {
|
|
|
|
+ string path;
|
|
|
|
+ var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
|
|
|
|
+ if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
|
{
|
|
{
|
|
- using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
|
|
|
|
|
|
+ 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")
|
|
{
|
|
{
|
|
- doc.Load(xml);
|
|
|
|
|
|
+ //maybe just couldn't find language - try just first one
|
|
|
|
+ node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo/@url");
|
|
}
|
|
}
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
-
|
|
|
|
- if (doc.HasChildNodes)
|
|
|
|
- {
|
|
|
|
- string path;
|
|
|
|
- var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
|
|
|
|
- if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
|
|
|
|
|
|
+ path = node != null ? node.Value : null;
|
|
|
|
+ if (!string.IsNullOrEmpty(path))
|
|
{
|
|
{
|
|
- 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")
|
|
|
|
|
|
+ Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- //maybe just couldn't find language - try just first one
|
|
|
|
- node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo/@url");
|
|
|
|
|
|
+ movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
}
|
|
}
|
|
- path = node != null ? node.Value : null;
|
|
|
|
- if (!string.IsNullOrEmpty(path))
|
|
|
|
|
|
+ catch (HttpException)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ catch (IOException)
|
|
{
|
|
{
|
|
- Logger.Debug("FanArtProvider getting ClearLogo for " + movie.Name);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- catch (IOException)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
+ }
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !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") ??
|
|
|
|
+ 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/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))
|
|
|
|
|
|
+ Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
+ }
|
|
|
|
+ catch (HttpException)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ catch (IOException)
|
|
{
|
|
{
|
|
- Logger.Debug("FanArtProvider getting ClearArt for " + movie.Name);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- catch (IOException)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
+ }
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !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");
|
|
|
|
+ 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))
|
|
|
|
|
|
+ Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
+ }
|
|
|
|
+ catch (HttpException)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ catch (IOException)
|
|
{
|
|
{
|
|
- Logger.Debug("FanArtProvider getting DiscArt for " + movie.Name);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- catch (IOException)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !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");
|
|
|
|
+ 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))
|
|
|
|
|
|
+ Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
+ }
|
|
|
|
+ catch (HttpException)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ catch (IOException)
|
|
{
|
|
{
|
|
- Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- catch (IOException)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
+ cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
- if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !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");
|
|
|
|
+ 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))
|
|
|
|
|
|
+ Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
+ }
|
|
|
|
+ catch (HttpException)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+ catch (IOException)
|
|
{
|
|
{
|
|
- Logger.Debug("FanArtProvider getting Banner for " + movie.Name);
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
|
|
|
- }
|
|
|
|
- catch (HttpException)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- catch (IOException)
|
|
|
|
- {
|
|
|
|
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|