slightly reduce simultaneous requests

This commit is contained in:
Luke Pulverenti 2013-05-19 17:20:47 -04:00
parent 40a2af83c9
commit b2b85d20a5
9 changed files with 50 additions and 50 deletions

View File

@ -97,7 +97,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
}; };
client = new HttpClient(handler); client = new HttpClient(handler);
client.Timeout = TimeSpan.FromSeconds(15); client.Timeout = TimeSpan.FromSeconds(30);
_httpClients.TryAdd(host, client); _httpClients.TryAdd(host, client);
} }

View File

@ -20,47 +20,47 @@ namespace MediaBrowser.Controller.Providers
public abstract class FanartBaseProvider : BaseMetadataProvider public abstract class FanartBaseProvider : BaseMetadataProvider
{ {
protected static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(5,5); protected static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3,3);
/// <summary> /// <summary>
/// The LOG o_ FILE /// The LOG o_ FILE
/// </summary> /// </summary>
protected const string LOGO_FILE = "logo.png"; protected const string LogoFile = "logo.png";
/// <summary> /// <summary>
/// The AR t_ FILE /// The AR t_ FILE
/// </summary> /// </summary>
protected const string ART_FILE = "clearart.png"; protected const string ArtFile = "clearart.png";
/// <summary> /// <summary>
/// The THUM b_ FILE /// The THUM b_ FILE
/// </summary> /// </summary>
protected const string THUMB_FILE = "thumb.jpg"; protected const string ThumbFile = "thumb.jpg";
/// <summary> /// <summary>
/// The DIS c_ FILE /// The DIS c_ FILE
/// </summary> /// </summary>
protected const string DISC_FILE = "disc.png"; protected const string DiscFile = "disc.png";
/// <summary> /// <summary>
/// The BANNE r_ FILE /// The BANNE r_ FILE
/// </summary> /// </summary>
protected const string BANNER_FILE = "banner.png"; protected const string BannerFile = "banner.png";
/// <summary> /// <summary>
/// The Backdrop /// The Backdrop
/// </summary> /// </summary>
protected const string BACKDROP_FILE = "backdrop.jpg"; protected const string BackdropFile = "backdrop.jpg";
/// <summary> /// <summary>
/// The Primary image /// The Primary image
/// </summary> /// </summary>
protected const string PRIMARY_FILE = "folder.jpg"; protected const string PrimaryFile = "folder.jpg";
/// <summary> /// <summary>
/// The API key /// The API key
/// </summary> /// </summary>
protected const string APIKey = "5c6b04c68e904cfed1e6cbc9a9e683d4"; protected const string ApiKey = "5c6b04c68e904cfed1e6cbc9a9e683d4";
protected FanartBaseProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager) protected FanartBaseProvider(ILogManager logManager, IServerConfigurationManager configurationManager) : base(logManager, configurationManager)
{ {

View File

@ -172,7 +172,7 @@ namespace MediaBrowser.Controller.Providers.Movies
var movie = item; var movie = item;
var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
var url = string.Format(FanArtBaseUrl, APIKey, movie.GetProviderId(MetadataProviders.Tmdb)); var url = string.Format(FanArtBaseUrl, ApiKey, movie.GetProviderId(MetadataProviders.Tmdb));
var doc = new XmlDocument(); var doc = new XmlDocument();
using (var xml = await HttpClient.Get(new HttpRequestOptions using (var xml = await HttpClient.Get(new HttpRequestOptions
@ -198,7 +198,7 @@ namespace MediaBrowser.Controller.Providers.Movies
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
var hasLogo = item.LocationType == LocationType.FileSystem ? var hasLogo = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE) item.ResolveArgs.ContainsMetaFileByName(LogoFile)
: item.HasImage(ImageType.Logo); : item.HasImage(ImageType.Logo);
if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !hasLogo) if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !hasLogo)
@ -214,13 +214,13 @@ namespace MediaBrowser.Controller.Providers.Movies
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, 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 hasArt = item.LocationType == LocationType.FileSystem ? var hasArt = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(ART_FILE) item.ResolveArgs.ContainsMetaFileByName(ArtFile)
: item.HasImage(ImageType.Art); : item.HasImage(ImageType.Art);
if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !hasArt) if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !hasArt)
@ -233,13 +233,13 @@ namespace MediaBrowser.Controller.Providers.Movies
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, 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 hasDisc = item.LocationType == LocationType.FileSystem ? var hasDisc = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(DISC_FILE) item.ResolveArgs.ContainsMetaFileByName(DiscFile)
: item.HasImage(ImageType.Disc); : item.HasImage(ImageType.Disc);
if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !hasDisc) if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !hasDisc)
@ -249,14 +249,14 @@ namespace MediaBrowser.Controller.Providers.Movies
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, 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 hasBanner = item.LocationType == LocationType.FileSystem ? var hasBanner = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE) item.ResolveArgs.ContainsMetaFileByName(BannerFile)
: item.HasImage(ImageType.Banner); : item.HasImage(ImageType.Banner);
if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !hasBanner) if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !hasBanner)
@ -266,14 +266,14 @@ namespace MediaBrowser.Controller.Providers.Movies
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BannerFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var hasThumb = item.LocationType == LocationType.FileSystem ? var hasThumb = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(THUMB_FILE) item.ResolveArgs.ContainsMetaFileByName(ThumbFile)
: item.HasImage(ImageType.Thumb); : item.HasImage(ImageType.Thumb);
if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !hasThumb) if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !hasThumb)
@ -283,12 +283,12 @@ namespace MediaBrowser.Controller.Providers.Movies
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, ThumbFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
var hasBackdrop = item.LocationType == LocationType.FileSystem ? var hasBackdrop = item.LocationType == LocationType.FileSystem ?
item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE) item.ResolveArgs.ContainsMetaFileByName(BackdropFile)
: item.BackdropImagePaths.Count > 0; : item.BackdropImagePaths.Count > 0;
if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && !hasBackdrop) if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && !hasBackdrop)

View File

@ -896,7 +896,7 @@ namespace MediaBrowser.Controller.Providers.Movies
try try
{ {
// Limit to three requests per second // Limit to three requests per second
var diff = 330 - (DateTime.Now - _lastRequestDate).TotalMilliseconds; var diff = 400 - (DateTime.Now - _lastRequestDate).TotalMilliseconds;
if (diff > 0) if (diff > 0)
{ {

View File

@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.Providers.Music
return true; return true;
} }
var url = string.Format("http://api.fanart.tv/webservice/album/{0}/{1}/xml/all/1/1", APIKey, album.MusicBrainzReleaseGroupId); var url = string.Format("http://api.fanart.tv/webservice/album/{0}/{1}/xml/all/1/1", ApiKey, album.MusicBrainzReleaseGroupId);
var doc = new XmlDocument(); var doc = new XmlDocument();
@ -154,7 +154,7 @@ namespace MediaBrowser.Controller.Providers.Music
if (doc.HasChildNodes) if (doc.HasChildNodes)
{ {
if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.ResolveArgs.ContainsMetaFileByName(DISC_FILE)) if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.ResolveArgs.ContainsMetaFileByName(DiscFile))
{ {
var node = doc.SelectSingleNode("//fanart/music/albums/album/cdart/@url"); var node = doc.SelectSingleNode("//fanart/music/albums/album/cdart/@url");
@ -163,11 +163,11 @@ namespace MediaBrowser.Controller.Providers.Music
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting Disc for " + item.Name); Logger.Debug("FanArtProvider getting Disc for " + item.Name);
item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DiscFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PRIMARY_FILE)) if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PrimaryFile))
{ {
var node = doc.SelectSingleNode("//fanart/music/albums/album/albumcover/@url"); var node = doc.SelectSingleNode("//fanart/music/albums/album/albumcover/@url");
@ -176,7 +176,7 @@ namespace MediaBrowser.Controller.Providers.Music
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting albumcover for " + item.Name); Logger.Debug("FanArtProvider getting albumcover for " + item.Name);
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PrimaryFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
} }

View File

@ -114,7 +114,7 @@ namespace MediaBrowser.Controller.Providers.Music
//var artist = item; //var artist = item;
var url = string.Format(FanArtBaseUrl, APIKey, item.GetProviderId(MetadataProviders.Musicbrainz)); var url = string.Format(FanArtBaseUrl, ApiKey, item.GetProviderId(MetadataProviders.Musicbrainz));
var doc = new XmlDocument(); var doc = new XmlDocument();
var status = ProviderRefreshStatus.Success; var status = ProviderRefreshStatus.Success;
@ -137,7 +137,7 @@ namespace MediaBrowser.Controller.Providers.Music
{ {
string path; string path;
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.ResolveArgs.ContainsMetaFileByName(LogoFile))
{ {
var node = var node =
doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ?? doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ??
@ -146,12 +146,12 @@ namespace MediaBrowser.Controller.Providers.Music
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name); Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name);
item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LogoFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && !item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE)) if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && !item.ResolveArgs.ContainsMetaFileByName(BackdropFile))
{ {
var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url"); var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url");
if (nodes != null) if (nodes != null)
@ -176,7 +176,7 @@ namespace MediaBrowser.Controller.Providers.Music
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ART_FILE)) if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.ResolveArgs.ContainsMetaFileByName(ArtFile))
{ {
var node = var node =
doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ?? doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ??
@ -185,12 +185,12 @@ namespace MediaBrowser.Controller.Providers.Music
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting ClearArt for " + item.Name); Logger.Debug("FanArtProvider getting ClearArt for " + item.Name);
item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ArtFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BANNER_FILE)) if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.ResolveArgs.ContainsMetaFileByName(BannerFile))
{ {
var node = doc.SelectSingleNode("//fanart/music/musicbanners/" + hd + "musicbanner/@url") ?? var node = doc.SelectSingleNode("//fanart/music/musicbanners/" + hd + "musicbanner/@url") ??
doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url"); doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url");
@ -198,21 +198,21 @@ namespace MediaBrowser.Controller.Providers.Music
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting Banner for " + item.Name); Logger.Debug("FanArtProvider getting Banner for " + item.Name);
item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BannerFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
// Artist thumbs are actually primary images (they are square/portrait) // Artist thumbs are actually primary images (they are square/portrait)
if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PRIMARY_FILE)) if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.ResolveArgs.ContainsMetaFileByName(PrimaryFile))
{ {
var node = doc.SelectSingleNode("//fanart/music/artistthumbs/artistthumb/@url"); var node = doc.SelectSingleNode("//fanart/music/artistthumbs/artistthumb/@url");
path = node != null ? node.Value : null; path = node != null ? node.Value : null;
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting Primary image for " + item.Name); Logger.Debug("FanArtProvider getting Primary image for " + item.Name);
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PrimaryFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
} }

View File

@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Providers.TV
var series = (Series)item; var series = (Series)item;
string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
string url = string.Format(FanArtBaseUrl, APIKey, series.GetProviderId(MetadataProviders.Tvdb)); string url = string.Format(FanArtBaseUrl, ApiKey, series.GetProviderId(MetadataProviders.Tvdb));
var doc = new XmlDocument(); var doc = new XmlDocument();
using (var xml = await HttpClient.Get(new HttpRequestOptions using (var xml = await HttpClient.Get(new HttpRequestOptions
@ -117,7 +117,7 @@ namespace MediaBrowser.Controller.Providers.TV
{ {
string path; string path;
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear"; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear";
if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LOGO_FILE)) if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LogoFile))
{ {
var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ?? 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/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ??
@ -127,14 +127,14 @@ namespace MediaBrowser.Controller.Providers.TV
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name); Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LogoFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ART_FILE)) if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ArtFile))
{ {
var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ?? 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/cleararts/clearart[@lang = \"" + language + "\"]/@url") ??
@ -144,13 +144,13 @@ namespace MediaBrowser.Controller.Providers.TV
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name); Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ArtFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.ResolveArgs.ContainsMetaFileByName(THUMB_FILE)) if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.ResolveArgs.ContainsMetaFileByName(ThumbFile))
{ {
var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ?? var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ??
doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url"); doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url");
@ -158,11 +158,11 @@ namespace MediaBrowser.Controller.Providers.TV
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name); Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); 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(BANNER_FILE)) if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.ResolveArgs.ContainsMetaFileByName(BannerFile))
{ {
var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ?? var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ??
doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url"); doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url");
@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.Providers.TV
if (!string.IsNullOrEmpty(path)) if (!string.IsNullOrEmpty(path))
{ {
Logger.Debug("FanArtProvider getting banner for " + series.Name); Logger.Debug("FanArtProvider getting banner for " + series.Name);
series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false)); series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BannerFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
} }
} }
} }

View File

@ -30,7 +30,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// <summary> /// <summary>
/// The tv db /// The tv db
/// </summary> /// </summary>
internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(5, 5); internal readonly SemaphoreSlim TvDbResourcePool = new SemaphoreSlim(3, 3);
internal static RemoteSeriesProvider Current { get; private set; } internal static RemoteSeriesProvider Current { get; private set; }

View File

@ -186,12 +186,12 @@ namespace MediaBrowser.Server.Implementations.Providers
// Put this check below the await because the needs refresh of the next tier of providers may depend on the previous ones running // Put this check below the await because the needs refresh of the next tier of providers may depend on the previous ones running
// This is the case for the fan art provider which depends on the movie and tv providers having run before them // This is the case for the fan art provider which depends on the movie and tv providers having run before them
if (!force && !provider.NeedsRefresh(item)) if (provider.RequiresInternet && item.DontFetchMeta)
{ {
continue; continue;
} }
if (provider.RequiresInternet && item.DontFetchMeta) if (!force && !provider.NeedsRefresh(item))
{ {
continue; continue;
} }