diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
index ed9e50f82a..9253b1bf7a 100644
--- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
+++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs
@@ -203,6 +203,8 @@ namespace MediaBrowser.Controller.Providers
throw new ArgumentNullException("providerInfo");
}
+ if (item.DontFetchMeta && RequiresInternet) return false;
+
if (CompareDate(item) > providerInfo.LastRefreshed)
{
return true;
@@ -218,6 +220,16 @@ namespace MediaBrowser.Controller.Providers
return true;
}
+ if (RequiresInternet && DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays)))
+ {
+ return true;
+ }
+
+ if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
+ {
+ return true;
+ }
+
return false;
}
diff --git a/MediaBrowser.Controller/Providers/FanartBaseProvider.cs b/MediaBrowser.Controller/Providers/FanartBaseProvider.cs
index fdac03c9a8..de749d7cc8 100644
--- a/MediaBrowser.Controller/Providers/FanartBaseProvider.cs
+++ b/MediaBrowser.Controller/Providers/FanartBaseProvider.cs
@@ -67,20 +67,6 @@ namespace MediaBrowser.Controller.Providers
{
}
- ///
- /// Needses the refresh internal.
- ///
- /// The item.
- /// The provider info.
- /// true if XXXX, false otherwise
- protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
- {
- if (item.DontFetchMeta) return false;
-
- return DateTime.UtcNow > (providerInfo.LastRefreshed.AddDays(ConfigurationManager.Configuration.MetadataRefreshDays))
- && ShouldFetch(item, providerInfo);
- }
-
///
/// Gets a value indicating whether [requires internet].
///
@@ -99,16 +85,6 @@ namespace MediaBrowser.Controller.Providers
get { return MetadataProviderPriority.Third; }
}
- ///
- /// Shoulds the fetch.
- ///
- /// The item.
- /// The provider info.
- /// true if XXXX, false otherwise
- protected virtual bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
- {
- return false;
- }
#region Result Objects
protected class FanArtImageInfo
diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
index b6155f6129..5453973698 100644
--- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@@ -57,7 +56,7 @@ namespace MediaBrowser.Controller.Providers.Movies
FanArtResourcePool.Dispose();
}
}
-
+
///
/// The fan art base URL
///
@@ -74,22 +73,26 @@ namespace MediaBrowser.Controller.Providers.Movies
}
///
- /// Shoulds the fetch.
+ /// Needses the refresh internal.
///
/// The item.
/// The provider info.
/// true if XXXX, false otherwise
- 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);
}
///
@@ -105,157 +108,148 @@ namespace MediaBrowser.Controller.Providers.Movies
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();
- }
- if (ShouldFetch(movie, providerData))
- {
- var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
- var url = string.Format(FanArtBaseUrl, APIKey, movie.GetProviderId(MetadataProviders.Tmdb));
- var doc = new XmlDocument();
-
- try
+ using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
{
- using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
+ doc.Load(xml);
+ }
+ }
+ 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))
+ {
+ 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");
+ }
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
+ {
+ 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)
+ {
+
+ }
}
}
- catch (HttpException)
+ cancellationToken.ThrowIfCancellationRequested();
+
+ 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))
+ {
+ 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();
+
+ 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))
+ {
+ 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();
- if (doc.HasChildNodes)
+ if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
{
- string path;
- var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
- if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_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/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ??
- doc.SelectSingleNode("//fanart/movie/movielogos/movielogo[@lang = \"" + language + "\"]/@url");
- if (node == null && language != "en")
+ Logger.Debug("FanArtProvider getting Banner 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.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_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();
+ }
- if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
+ cancellationToken.ThrowIfCancellationRequested();
+
+ 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/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 Banner for " + movie.Name);
+ try
{
- 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)
- {
-
- }
+ movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
- }
- cancellationToken.ThrowIfCancellationRequested();
-
- 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))
+ catch (HttpException)
{
- 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();
-
- 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))
+ 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();
-
- 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))
- {
- 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)
- {
-
- }
}
}
}
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
index 4d7f78413d..ac9d0ae540 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
@@ -31,19 +31,6 @@ namespace MediaBrowser.Controller.Providers.Music
return item is MusicAlbum;
}
- ///
- /// Needses the refresh internal.
- ///
- /// The item.
- /// The provider info.
- /// true if we need refreshing, false otherwise
- protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
- {
- //we fetch if image needed and haven't already tried recently
- return (string.IsNullOrEmpty(item.PrimaryImagePath) || !item.HasImage(ImageType.Disc)) &&
- DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
- }
-
public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
var mbid = item.GetProviderId(MetadataProviders.Musicbrainz);
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
index 1d4d811b65..ba07da2c12 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
@@ -1,8 +1,6 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
@@ -60,18 +58,28 @@ namespace MediaBrowser.Controller.Providers.Music
}
///
- /// Shoulds the fetch.
+ /// Needses the refresh internal.
///
/// The item.
/// The provider info.
/// true if XXXX, false otherwise
- protected override bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
+ protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- if (item.Path == null || item.DontFetchMeta || string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz))) return false; //nothing to do
+ if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz)))
+ {
+ return false;
+ }
- return (!item.ResolveArgs.ContainsMetaFileByName(ART_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Art)
- || (!item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo)
- || (!item.ResolveArgs.ContainsMetaFileByName(DISC_FILE) && ConfigurationManager.Configuration.DownloadMusicArtistImages.Disc);
+ if (!ConfigurationManager.Configuration.DownloadMusicArtistImages.Art &&
+ !ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops &&
+ !ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner &&
+ !ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo &&
+ !ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary)
+ {
+ return false;
+ }
+
+ return base.NeedsRefreshInternal(item, providerInfo);
}
///
@@ -87,165 +95,156 @@ namespace MediaBrowser.Controller.Providers.Music
//var artist = item;
- BaseProviderInfo providerData;
+ var url = string.Format(FanArtBaseUrl, APIKey, item.GetProviderId(MetadataProviders.Musicbrainz));
+ var doc = new XmlDocument();
- if (!item.ProviderData.TryGetValue(Id, out providerData))
+ try
+ {
+ using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
+ {
+ doc.Load(xml);
+ }
+ }
+ catch (HttpException)
{
- providerData = new BaseProviderInfo();
}
- if (ShouldFetch(item, providerData))
- {
- var url = string.Format(FanArtBaseUrl, APIKey, item.GetProviderId(MetadataProviders.Musicbrainz));
- var doc = new XmlDocument();
+ cancellationToken.ThrowIfCancellationRequested();
- try
+ if (doc.HasChildNodes)
+ {
+ string path;
+ var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
+ if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
{
- using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
+ var node =
+ doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ??
+ doc.SelectSingleNode("//fanart/music/musiclogos/musiclogo/@url");
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
{
- doc.Load(xml);
+ Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name);
+ try
+ {
+ item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ }
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
+ {
+
+ }
}
}
- catch (HttpException)
+ cancellationToken.ThrowIfCancellationRequested();
+
+ if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && !item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE))
{
+ var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url");
+ if (nodes != null)
+ {
+ var numBackdrops = 0;
+ item.BackdropImagePaths = new List();
+ foreach (XmlNode node in nodes)
+ {
+ path = node.Value;
+ if (!string.IsNullOrEmpty(path))
+ {
+ Logger.Debug("FanArtProvider getting Backdrop for " + item.Name);
+ try
+ {
+ item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString() : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ numBackdrops++;
+ if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
+ }
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
+ {
+
+ }
+ }
+ }
+
+ }
+
}
cancellationToken.ThrowIfCancellationRequested();
- if (doc.HasChildNodes)
+ if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
{
- string path;
- var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
- if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
+ var node =
+ doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ??
+ doc.SelectSingleNode("//fanart/music/musicarts/musicart/@url");
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
{
- var node =
- doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ??
- doc.SelectSingleNode("//fanart/music/musiclogos/musiclogo/@url");
- path = node != null ? node.Value : null;
- if (!string.IsNullOrEmpty(path))
+ Logger.Debug("FanArtProvider getting ClearArt for " + item.Name);
+ try
+ {
+ item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ }
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
{
- Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name);
- try
- {
- item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
- }
}
}
- cancellationToken.ThrowIfCancellationRequested();
+ }
+ cancellationToken.ThrowIfCancellationRequested();
- if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && !item.ResolveArgs.ContainsMetaFileByName(BACKDROP_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");
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
{
- var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url");
- if (nodes != null)
+ Logger.Debug("FanArtProvider getting Banner for " + item.Name);
+ try
{
- var numBackdrops = 0;
- item.BackdropImagePaths = new List();
- foreach (XmlNode node in nodes)
- {
- path = node.Value;
- if (!string.IsNullOrEmpty(path))
- {
- Logger.Debug("FanArtProvider getting Backdrop for " + item.Name);
- try
- {
- item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString() : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- numBackdrops++;
- if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
-
- }
- }
- }
-
+ item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
-
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE))
- {
- var node =
- doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ??
- doc.SelectSingleNode("//fanart/music/musicarts/musicart/@url");
- path = node != null ? node.Value : null;
- if (!string.IsNullOrEmpty(path))
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
{
- Logger.Debug("FanArtProvider getting ClearArt for " + item.Name);
- try
- {
- item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
- }
}
}
- cancellationToken.ThrowIfCancellationRequested();
+ }
- if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
+ cancellationToken.ThrowIfCancellationRequested();
+
+ // Artist thumbs are actually primary images (they are square/portrait)
+ 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;
+ if (!string.IsNullOrEmpty(path))
{
- var node = doc.SelectSingleNode("//fanart/music/musicbanners/"+hd+"musicbanner/@url") ??
- doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url");
- path = node != null ? node.Value : null;
- if (!string.IsNullOrEmpty(path))
+ Logger.Debug("FanArtProvider getting Primary image for " + item.Name);
+ try
{
- Logger.Debug("FanArtProvider getting Banner for " + item.Name);
- try
- {
- item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
-
- }
+ item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- // Artist thumbs are actually primary images (they are square/portrait)
- 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;
- if (!string.IsNullOrEmpty(path))
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
{
- Logger.Debug("FanArtProvider getting Primary image for " + item.Name);
- try
- {
- item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
- }
}
}
}
}
+
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
index fefd6eed6f..f8c9685f77 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmBaseProvider.cs
@@ -168,36 +168,6 @@ namespace MediaBrowser.Controller.Providers.Music
return WebUtility.UrlEncode(name);
}
- protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
- {
- if (item.DontFetchMeta) return false;
-
- if (RefreshOnFileSystemStampChange && HasFileSystemStampChanged(item, providerInfo))
- {
- //If they deleted something from file system, chances are, this item was mis-identified the first time
- item.SetProviderId(MetadataProviders.Musicbrainz, null);
- Logger.Debug("LastfmProvider reports file system stamp change...");
- return true;
- }
-
- if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
- {
- Logger.Debug("LastfmProvider for {0} - last attempt had errors. Will try again.", item.Path);
- return true;
- }
-
- if (RefreshOnVersionChange && ProviderVersion != providerInfo.ProviderVersion)
- {
- Logger.Debug("LastfmProvider version change re-running for {0}", item.Path);
- return true;
- }
-
- if (DateTime.UtcNow.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days
- return true;
-
- return false;
- }
-
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
index c974d58575..26053a39d6 100644
--- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs
@@ -1,5 +1,4 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
@@ -25,7 +24,7 @@ namespace MediaBrowser.Controller.Providers.TV
protected IHttpClient HttpClient { get; private set; }
private readonly IProviderManager _providerManager;
-
+
public FanArtTvProvider(IHttpClient httpClient, ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager)
: base(logManager, configurationManager)
{
@@ -42,17 +41,27 @@ namespace MediaBrowser.Controller.Providers.TV
return item is Series;
}
- protected override bool ShouldFetch(BaseItem item, BaseProviderInfo providerInfo)
+ ///
+ /// Needses the refresh internal.
+ ///
+ /// The item.
+ /// The provider info.
+ /// true if XXXX, false otherwise
+ protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- if (item.DontFetchMeta || string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tvdb))) return false; //nothing to do
- var artExists = item.ResolveArgs.ContainsMetaFileByName(ART_FILE);
- var logoExists = item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE);
- var thumbExists = item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE);
+ if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tvdb)))
+ {
+ return false;
+ }
+ if (!ConfigurationManager.Configuration.DownloadSeriesImages.Art &&
+ !ConfigurationManager.Configuration.DownloadSeriesImages.Logo &&
+ !ConfigurationManager.Configuration.DownloadSeriesImages.Thumb)
+ {
+ return false;
+ }
- return (!artExists && ConfigurationManager.Configuration.DownloadSeriesImages.Art)
- || (!logoExists && ConfigurationManager.Configuration.DownloadSeriesImages.Logo)
- || (!thumbExists && ConfigurationManager.Configuration.DownloadSeriesImages.Thumb);
+ return base.NeedsRefreshInternal(item, providerInfo);
}
public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
@@ -61,113 +70,105 @@ namespace MediaBrowser.Controller.Providers.TV
var series = (Series)item;
- BaseProviderInfo providerData;
+ string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
+ string url = string.Format(FanArtBaseUrl, APIKey, series.GetProviderId(MetadataProviders.Tvdb));
+ var doc = new XmlDocument();
- if (!item.ProviderData.TryGetValue(Id, out providerData))
+ try
+ {
+ using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
+ {
+ doc.Load(xml);
+ }
+ }
+ catch (HttpException)
{
- providerData = new BaseProviderInfo();
}
- if (ShouldFetch(series, providerData))
- {
- string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
- string url = string.Format(FanArtBaseUrl, APIKey, series.GetProviderId(MetadataProviders.Tvdb));
- var doc = new XmlDocument();
+ cancellationToken.ThrowIfCancellationRequested();
- try
+ if (doc.HasChildNodes)
+ {
+ string path;
+ var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear";
+ if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
{
- using (var xml = await HttpClient.Get(url, FanArtResourcePool, cancellationToken).ConfigureAwait(false))
+ 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))
{
- doc.Load(xml);
+ Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
+ try
+ {
+ series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ }
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
+ {
+
+ }
}
}
- catch (HttpException)
- {
- }
cancellationToken.ThrowIfCancellationRequested();
- if (doc.HasChildNodes)
+ hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
+ if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE))
{
- string path;
- var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear";
- if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE))
+ 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))
{
- 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 ClearArt for " + series.Name);
+ try
+ {
+ series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ }
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
{
- Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
- try
- {
- series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
- }
}
}
+ }
- cancellationToken.ThrowIfCancellationRequested();
+ cancellationToken.ThrowIfCancellationRequested();
- hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
- if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ART_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");
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
{
- 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 ThumbArt for " + series.Name);
+ try
{
- Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
- try
- {
- series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
-
- }
+ series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
}
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- 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");
- path = node != null ? node.Value : null;
- if (!string.IsNullOrEmpty(path))
+ catch (HttpException)
+ {
+ }
+ catch (IOException)
{
- Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
- try
- {
- series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
- }
}
}
}
}
+
SetLastRefreshed(series, DateTime.UtcNow);
+
return true;
}
}
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
index ba3df07b40..34c4752f9e 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
@@ -96,22 +96,12 @@ namespace MediaBrowser.Controller.Providers.TV
/// true if XXXX, false otherwise
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- bool fetch = false;
- var episode = (Episode)item;
- var downloadDate = providerInfo.LastRefreshed;
-
- if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
+ if (HasLocalMeta(item))
{
return false;
}
- if (!item.DontFetchMeta && !HasLocalMeta(episode))
- {
- fetch = ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
- DateTime.Today.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
- }
-
- return fetch;
+ return base.NeedsRefreshInternal(item, providerInfo);
}
///
@@ -313,7 +303,7 @@ namespace MediaBrowser.Controller.Providers.TV
///
/// The episode.
/// true if [has local meta] [the specified episode]; otherwise, false.
- private bool HasLocalMeta(Episode episode)
+ private bool HasLocalMeta(BaseItem episode)
{
return (episode.Parent.ResolveArgs.ContainsMetaFileByName(Path.GetFileNameWithoutExtension(episode.Path) + ".xml"));
}
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
index 9d1a7c2566..a30b8f83f0 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
@@ -78,19 +78,12 @@ namespace MediaBrowser.Controller.Providers.TV
/// true if XXXX, false otherwise
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- bool fetch = false;
- var downloadDate = providerInfo.LastRefreshed;
-
- if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
- return false;
-
- if (!HasLocalMeta(item))
+ if (HasLocalMeta(item))
{
- fetch = ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
- DateTime.UtcNow.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
+ return false;
}
- return fetch;
+ return base.NeedsRefreshInternal(item, providerInfo);
}
///