diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 3e8eed152a..62e92d7f2f 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -72,6 +72,7 @@
+
diff --git a/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs b/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs
index 9ddc0a33fa..6c7c85aa3f 100644
--- a/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs
+++ b/MediaBrowser.Controller/Providers/MetadataProviderPriority.cs
@@ -24,10 +24,15 @@ namespace MediaBrowser.Controller.Providers
///
Third = 3,
+ ///
+ /// The fourth
+ ///
+ Fourth = 4,
+
// Run this provider last
///
/// The last
///
- Last = 4
+ Last = 5
}
}
diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
index aebc4a234b..3644f5633f 100644
--- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@@ -6,7 +7,8 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
-using System.IO;
+using System.Collections.Generic;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
@@ -26,6 +28,8 @@ namespace MediaBrowser.Controller.Providers.Movies
private readonly IProviderManager _providerManager;
+ private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
+
///
/// Initializes a new instance of the class.
///
@@ -57,6 +61,30 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
+ ///
+ /// Gets a value indicating whether [refresh on version change].
+ ///
+ /// true if [refresh on version change]; otherwise, false.
+ protected override bool RefreshOnVersionChange
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Gets the provider version.
+ ///
+ /// The provider version.
+ protected override string ProviderVersion
+ {
+ get
+ {
+ return "12";
+ }
+ }
+
///
/// The fan art base URL
///
@@ -92,9 +120,18 @@ namespace MediaBrowser.Controller.Providers.Movies
return false;
}
+ // Refresh if tmdb id has changed
+ if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb)))
+ {
+ return true;
+ }
+
if (!ConfigurationManager.Configuration.DownloadMovieImages.Art &&
!ConfigurationManager.Configuration.DownloadMovieImages.Logo &&
- !ConfigurationManager.Configuration.DownloadMovieImages.Disc)
+ !ConfigurationManager.Configuration.DownloadMovieImages.Disc &&
+ !ConfigurationManager.Configuration.DownloadMovieImages.Backdrops &&
+ !ConfigurationManager.Configuration.DownloadMovieImages.Banner &&
+ !ConfigurationManager.Configuration.DownloadMovieImages.Thumb)
{
return false;
}
@@ -102,6 +139,15 @@ namespace MediaBrowser.Controller.Providers.Movies
return base.NeedsRefreshInternal(item, providerInfo);
}
+ ///
+ /// Gets the comparison data.
+ ///
+ /// Guid.
+ private Guid GetComparisonData(string id)
+ {
+ return string.IsNullOrEmpty(id) ? Guid.Empty : id.GetMD5();
+ }
+
///
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
///
@@ -113,28 +159,32 @@ namespace MediaBrowser.Controller.Providers.Movies
{
cancellationToken.ThrowIfCancellationRequested();
+ BaseProviderInfo data;
+
+ if (!item.ProviderData.TryGetValue(Id, out data))
+ {
+ data = new BaseProviderInfo();
+ item.ProviderData[Id] = data;
+ }
+
+ var status = ProviderRefreshStatus.Success;
+
var movie = item;
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(new HttpRequestOptions
{
- using (var xml = await HttpClient.Get(new HttpRequestOptions
- {
- Url = url,
- ResourcePool = FanArtResourcePool,
- CancellationToken = cancellationToken,
- EnableResponseCache = true
+ Url = url,
+ ResourcePool = FanArtResourcePool,
+ CancellationToken = cancellationToken,
+ EnableResponseCache = true
- }).ConfigureAwait(false))
- {
- doc.Load(xml);
- }
- }
- catch (HttpException)
+ }).ConfigureAwait(false))
{
+ doc.Load(xml);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -170,10 +220,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -199,10 +246,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -225,10 +269,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -252,10 +293,7 @@ namespace MediaBrowser.Controller.Providers.Movies
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -279,15 +317,49 @@ namespace MediaBrowser.Controller.Providers.Movies
}
catch (HttpException)
{
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
- catch (IOException)
- {
+ }
+ }
+
+ var hasBackdrop = item.LocationType == LocationType.FileSystem ?
+ item.ResolveArgs.ContainsMetaFileByName(BACKDROP_FILE)
+ : item.BackdropImagePaths.Count > 0;
+ if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && !hasBackdrop)
+ {
+ var nodes = doc.SelectNodes("//fanart/movie/moviebackgrounds//@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(UsCulture) : "") + ".jpg"), saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
+ numBackdrops++;
+ if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
+ }
+ catch (HttpException)
+ {
+ status = ProviderRefreshStatus.CompletedWithErrors;
+ }
+ }
}
+
}
+
}
+
}
- SetLastRefreshed(movie, DateTime.UtcNow);
+
+ data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb));
+ SetLastRefreshed(movie, DateTime.UtcNow, status);
return true;
}
diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs
new file mode 100644
index 0000000000..7aeb976bf7
--- /dev/null
+++ b/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs
@@ -0,0 +1,408 @@
+using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Movies;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Net;
+using MediaBrowser.Model.Serialization;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Providers.Movies
+{
+ ///
+ /// Class MovieDbImagesProvider
+ ///
+ public class MovieDbImagesProvider : BaseMetadataProvider
+ {
+ ///
+ /// The get images
+ ///
+ private const string GetImages = @"http://api.themoviedb.org/3/{2}/{0}/images?api_key={1}";
+
+ ///
+ /// The _provider manager
+ ///
+ private readonly IProviderManager _providerManager;
+
+ ///
+ /// The _json serializer
+ ///
+ private readonly IJsonSerializer _jsonSerializer;
+
+ ///
+ /// The _HTTP client
+ ///
+ private readonly IHttpClient _httpClient;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The log manager.
+ /// The configuration manager.
+ /// The provider manager.
+ /// The json serializer.
+ /// The HTTP client.
+ public MovieDbImagesProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ : base(logManager, configurationManager)
+ {
+ _providerManager = providerManager;
+ _jsonSerializer = jsonSerializer;
+ _httpClient = httpClient;
+ }
+
+ ///
+ /// Gets the priority.
+ ///
+ /// The priority.
+ public override MetadataProviderPriority Priority
+ {
+ get { return MetadataProviderPriority.Fourth; }
+ }
+
+ ///
+ /// Supports the specified item.
+ ///
+ /// The item.
+ /// true if XXXX, false otherwise
+ public override bool Supports(BaseItem item)
+ {
+ var trailer = item as Trailer;
+
+ if (trailer != null)
+ {
+ return !trailer.IsLocalTrailer;
+ }
+
+ // Don't support local trailers
+ return item is Movie || item is BoxSet;
+ }
+
+ ///
+ /// Gets a value indicating whether [requires internet].
+ ///
+ /// true if [requires internet]; otherwise, false.
+ public override bool RequiresInternet
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// If we save locally, refresh if they delete something
+ ///
+ /// true if [refresh on file system stamp change]; otherwise, false.
+ protected override bool RefreshOnFileSystemStampChange
+ {
+ get
+ {
+ return ConfigurationManager.Configuration.SaveLocalMeta;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether [refresh on version change].
+ ///
+ /// true if [refresh on version change]; otherwise, false.
+ protected override bool RefreshOnVersionChange
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ ///
+ /// Gets the provider version.
+ ///
+ /// The provider version.
+ protected override string ProviderVersion
+ {
+ get
+ {
+ return "3";
+ }
+ }
+
+ ///
+ /// Needses the refresh internal.
+ ///
+ /// The item.
+ /// The provider info.
+ /// true if XXXX, false otherwise
+ protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
+ {
+ if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb)))
+ {
+ return false;
+ }
+
+ // Refresh if tmdb id has changed
+ if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb)))
+ {
+ return true;
+ }
+
+ return base.NeedsRefreshInternal(item, providerInfo);
+ }
+
+ ///
+ /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
+ ///
+ /// The item.
+ /// if set to true [force].
+ /// The cancellation token
+ /// Task{System.Boolean}.
+ public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
+ {
+ BaseProviderInfo data;
+
+ if (!item.ProviderData.TryGetValue(Id, out data))
+ {
+ data = new BaseProviderInfo();
+ item.ProviderData[Id] = data;
+ }
+
+ var images = await FetchImages(item, item.GetProviderId(MetadataProviders.Tmdb), cancellationToken).ConfigureAwait(false);
+
+ var status = await ProcessImages(item, images, cancellationToken).ConfigureAwait(false);
+
+ data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb));
+
+ SetLastRefreshed(item, DateTime.UtcNow, status);
+ return true;
+ }
+
+ ///
+ /// Gets the comparison data.
+ ///
+ /// Guid.
+ private Guid GetComparisonData(string id)
+ {
+ return string.IsNullOrEmpty(id) ? Guid.Empty : id.GetMD5();
+ }
+
+ ///
+ /// Fetches the images.
+ ///
+ /// The item.
+ /// The id.
+ /// The cancellation token.
+ /// Task{MovieImages}.
+ private async Task FetchImages(BaseItem item, string id, CancellationToken cancellationToken)
+ {
+ using (var json = await _httpClient.Get(new HttpRequestOptions
+ {
+ Url = string.Format(GetImages, id, MovieDbProvider.ApiKey, item is BoxSet ? "collection" : "movie"),
+ CancellationToken = cancellationToken,
+ ResourcePool = MovieDbProvider.Current.MovieDbResourcePool,
+ AcceptHeader = MovieDbProvider.AcceptHeader,
+ EnableResponseCache = true
+
+ }).ConfigureAwait(false))
+ {
+ return _jsonSerializer.DeserializeFromStream(json);
+ }
+ }
+
+ ///
+ /// Processes the images.
+ ///
+ /// The item.
+ /// The images.
+ /// The cancellation token
+ /// Task.
+ protected virtual async Task ProcessImages(BaseItem item, MovieImages images, CancellationToken cancellationToken)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var status = ProviderRefreshStatus.Success;
+
+ var hasLocalPoster = item.LocationType == LocationType.FileSystem ? item.HasLocalImage("folder") : item.HasImage(ImageType.Primary);
+
+ // poster
+ if (images.posters != null && images.posters.Count > 0 && (ConfigurationManager.Configuration.RefreshItemImages || !hasLocalPoster))
+ {
+ var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
+
+ var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
+ // get highest rated poster for our language
+
+ var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
+
+ var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
+ if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
+ {
+ // couldn't find our specific language, find english (if that wasn't our language)
+ poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase));
+ }
+ if (poster == null)
+ {
+ //still couldn't find it - try highest rated null one
+ poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 == null);
+ }
+ if (poster == null)
+ {
+ //finally - just get the highest rated one
+ poster = postersSortedByVote.FirstOrDefault();
+ }
+ if (poster != null)
+ {
+ try
+ {
+ item.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false);
+ }
+ catch (HttpException)
+ {
+ status = ProviderRefreshStatus.CompletedWithErrors;
+ }
+ }
+ }
+
+ cancellationToken.ThrowIfCancellationRequested();
+
+ // backdrops
+ if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops)
+ {
+ item.BackdropImagePaths = new List();
+
+ var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
+
+ var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
+ //backdrops should be in order of rating. get first n ones
+ var numToFetch = Math.Min(ConfigurationManager.Configuration.MaxBackdrops, images.backdrops.Count);
+ for (var i = 0; i < numToFetch; i++)
+ {
+ var bdName = "backdrop" + (i == 0 ? "" : i.ToString(CultureInfo.InvariantCulture));
+
+ var hasLocalBackdrop = item.LocationType == LocationType.FileSystem ? item.HasLocalImage(bdName) : item.BackdropImagePaths.Count > i;
+
+ if (ConfigurationManager.Configuration.RefreshItemImages || !hasLocalBackdrop)
+ {
+ try
+ {
+ item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem, MovieDbProvider.Current.MovieDbResourcePool, cancellationToken).ConfigureAwait(false));
+ }
+ catch (HttpException)
+ {
+ status = ProviderRefreshStatus.CompletedWithErrors;
+ }
+ }
+ }
+ }
+
+ return status;
+ }
+
+ ///
+ /// Class Backdrop
+ ///
+ protected class Backdrop
+ {
+ ///
+ /// Gets or sets the file_path.
+ ///
+ /// The file_path.
+ public string file_path { get; set; }
+ ///
+ /// Gets or sets the width.
+ ///
+ /// The width.
+ public int width { get; set; }
+ ///
+ /// Gets or sets the height.
+ ///
+ /// The height.
+ public int height { get; set; }
+ ///
+ /// Gets or sets the iso_639_1.
+ ///
+ /// The iso_639_1.
+ public string iso_639_1 { get; set; }
+ ///
+ /// Gets or sets the aspect_ratio.
+ ///
+ /// The aspect_ratio.
+ public double aspect_ratio { get; set; }
+ ///
+ /// Gets or sets the vote_average.
+ ///
+ /// The vote_average.
+ public double vote_average { get; set; }
+ ///
+ /// Gets or sets the vote_count.
+ ///
+ /// The vote_count.
+ public int vote_count { get; set; }
+ }
+
+ ///
+ /// Class Poster
+ ///
+ protected class Poster
+ {
+ ///
+ /// Gets or sets the file_path.
+ ///
+ /// The file_path.
+ public string file_path { get; set; }
+ ///
+ /// Gets or sets the width.
+ ///
+ /// The width.
+ public int width { get; set; }
+ ///
+ /// Gets or sets the height.
+ ///
+ /// The height.
+ public int height { get; set; }
+ ///
+ /// Gets or sets the iso_639_1.
+ ///
+ /// The iso_639_1.
+ public string iso_639_1 { get; set; }
+ ///
+ /// Gets or sets the aspect_ratio.
+ ///
+ /// The aspect_ratio.
+ public double aspect_ratio { get; set; }
+ ///
+ /// Gets or sets the vote_average.
+ ///
+ /// The vote_average.
+ public double vote_average { get; set; }
+ ///
+ /// Gets or sets the vote_count.
+ ///
+ /// The vote_count.
+ public int vote_count { get; set; }
+ }
+
+ ///
+ /// Class MovieImages
+ ///
+ protected class MovieImages
+ {
+ ///
+ /// Gets or sets the backdrops.
+ ///
+ /// The backdrops.
+ public List backdrops { get; set; }
+ ///
+ /// Gets or sets the posters.
+ ///
+ /// The posters.
+ public List posters { get; set; }
+ }
+
+ }
+}
diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
index 51a98a38d8..a6d3025148 100644
--- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs
@@ -274,7 +274,6 @@ namespace MediaBrowser.Controller.Providers.Movies
private const string TmdbConfigUrl = "http://api.themoviedb.org/3/configuration?api_key={0}";
private const string Search3 = @"http://api.themoviedb.org/3/search/movie?api_key={1}&query={0}&language={2}";
private const string AltTitleSearch = @"http://api.themoviedb.org/3/movie/{0}/alternative_titles?api_key={1}&country={2}";
- private const string GetImages = @"http://api.themoviedb.org/3/{2}/{0}/images?api_key={1}";
private const string GetMovieInfo3 = @"http://api.themoviedb.org/3/movie/{0}?api_key={1}&language={2}&append_to_response=casts,releases,images,keywords";
private const string GetBoxSetInfo3 = @"http://api.themoviedb.org/3/collection/{0}?api_key={1}&language={2}&append_to_response=images";
@@ -793,10 +792,6 @@ namespace MediaBrowser.Controller.Providers.Movies
cancellationToken.ThrowIfCancellationRequested();
- mainResult.images = await FetchImages(item, id, cancellationToken).ConfigureAwait(false);
-
- await ProcessImages(item, mainResult.images, cancellationToken).ConfigureAwait(false);
-
//and save locally
if (ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem)
{
@@ -809,22 +804,6 @@ namespace MediaBrowser.Controller.Providers.Movies
}
}
- private async Task FetchImages(BaseItem item, string id, CancellationToken cancellationToken)
- {
- using (var json = await HttpClient.Get(new HttpRequestOptions
- {
- Url = string.Format(GetImages, id, ApiKey, item is BoxSet ? "collection" : "movie"),
- CancellationToken = cancellationToken,
- ResourcePool = Current.MovieDbResourcePool,
- AcceptHeader = AcceptHeader,
- EnableResponseCache = true
-
- }).ConfigureAwait(false))
- {
- return JsonSerializer.DeserializeFromStream(json);
- }
- }
-
///
/// Fetches the main result.
///
@@ -1043,97 +1022,6 @@ namespace MediaBrowser.Controller.Providers.Movies
}
- ///
- /// Processes the images.
- ///
- /// The item.
- /// The images.
- /// The cancellation token
- /// Task.
- protected virtual async Task ProcessImages(BaseItem item, MovieImages images, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- var hasLocalPoster = item.LocationType == LocationType.FileSystem ? item.HasLocalImage("folder") : item.HasImage(ImageType.Primary);
-
- // poster
- if (images.posters != null && images.posters.Count > 0 && (ConfigurationManager.Configuration.RefreshItemImages || !hasLocalPoster))
- {
- var tmdbSettings = await TmdbSettings.ConfigureAwait(false);
-
- var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
- // get highest rated poster for our language
-
- var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
-
- var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
- if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
- {
- // couldn't find our specific language, find english (if that wasn't our language)
- poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase));
- }
- if (poster == null)
- {
- //still couldn't find it - try highest rated null one
- poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 == null);
- }
- if (poster == null)
- {
- //finally - just get the highest rated one
- poster = postersSortedByVote.FirstOrDefault();
- }
- if (poster != null)
- {
- try
- {
- item.PrimaryImagePath = await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + poster.file_path, "folder" + Path.GetExtension(poster.file_path), ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem, MovieDbResourcePool, cancellationToken).ConfigureAwait(false);
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
-
- }
- }
- }
-
- cancellationToken.ThrowIfCancellationRequested();
-
- // backdrops
- if (images.backdrops != null && images.backdrops.Count > 0)
- {
- item.BackdropImagePaths = new List();
-
- var tmdbSettings = await TmdbSettings.ConfigureAwait(false);
-
- var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
- //backdrops should be in order of rating. get first n ones
- var numToFetch = Math.Min(ConfigurationManager.Configuration.MaxBackdrops, images.backdrops.Count);
- for (var i = 0; i < numToFetch; i++)
- {
- var bdName = "backdrop" + (i == 0 ? "" : i.ToString(CultureInfo.InvariantCulture));
-
- var hasLocalBackdrop = item.LocationType == LocationType.FileSystem ? item.HasLocalImage(bdName) : item.BackdropImagePaths.Count > i;
-
- if (ConfigurationManager.Configuration.RefreshItemImages || !hasLocalBackdrop)
- {
- try
- {
- item.BackdropImagePaths.Add(await ProviderManager.DownloadAndSaveImage(item, tmdbImageUrl + images.backdrops[i].file_path, bdName + Path.GetExtension(images.backdrops[i].file_path), ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem, MovieDbResourcePool, cancellationToken).ConfigureAwait(false));
- }
- catch (HttpException)
- {
- }
- catch (IOException)
- {
-
- }
- }
- }
- }
- }
-
///
/// The remove
@@ -1445,34 +1333,6 @@ namespace MediaBrowser.Controller.Providers.Movies
public List countries { get; set; }
}
- protected class Backdrop
- {
- public string file_path { get; set; }
- public int width { get; set; }
- public int height { get; set; }
- public string iso_639_1 { get; set; }
- public double aspect_ratio { get; set; }
- public double vote_average { get; set; }
- public int vote_count { get; set; }
- }
-
- protected class Poster
- {
- public string file_path { get; set; }
- public int width { get; set; }
- public int height { get; set; }
- public string iso_639_1 { get; set; }
- public double aspect_ratio { get; set; }
- public double vote_average { get; set; }
- public int vote_count { get; set; }
- }
-
- protected class MovieImages
- {
- public List backdrops { get; set; }
- public List posters { get; set; }
- }
-
protected class Keyword
{
public int id { get; set; }
@@ -1511,7 +1371,6 @@ namespace MediaBrowser.Controller.Providers.Movies
public int vote_count { get; set; }
public Casts casts { get; set; }
public Releases releases { get; set; }
- public MovieImages images { get; set; }
public Keywords keywords { get; set; }
}
diff --git a/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
index 10ddb4516c..da870e77d8 100644
--- a/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/OpenMovieDatabaseProvider.cs
@@ -121,7 +121,7 @@ namespace MediaBrowser.Controller.Providers.Movies
/// true if XXXX, false otherwise
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
- // Refresh if rt id has changed
+ // Refresh if imdb id has changed
if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Imdb)))
{
return true;
diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
index 2993d39da1..4a5fa8ca25 100644
--- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
+++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs
@@ -204,23 +204,17 @@ namespace MediaBrowser.Controller.Providers.Movies
string url = string.Format(@"http://api.themoviedb.org/3/person/{1}?api_key={0}&append_to_response=credits,images", MovieDbProvider.ApiKey, id);
PersonResult searchResult = null;
- try
+ using (var json = await HttpClient.Get(new HttpRequestOptions
{
- using (var json = await HttpClient.Get(new HttpRequestOptions
- {
- Url = url,
- CancellationToken = cancellationToken,
- ResourcePool = MovieDbProvider.Current.MovieDbResourcePool,
- AcceptHeader = MovieDbProvider.AcceptHeader,
- EnableResponseCache = true
+ Url = url,
+ CancellationToken = cancellationToken,
+ ResourcePool = MovieDbProvider.Current.MovieDbResourcePool,
+ AcceptHeader = MovieDbProvider.AcceptHeader,
+ EnableResponseCache = true
- }).ConfigureAwait(false))
- {
- searchResult = JsonSerializer.DeserializeFromStream(json);
- }
- }
- catch (HttpException)
+ }).ConfigureAwait(false))
{
+ searchResult = JsonSerializer.DeserializeFromStream(json);
}
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
index 23960a34f2..7683cbafb8 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs
@@ -139,22 +139,18 @@ namespace MediaBrowser.Controller.Providers.Music
var doc = new XmlDocument();
- try
+ var status = ProviderRefreshStatus.Success;
+
+ using (var xml = await HttpClient.Get(new HttpRequestOptions
{
- using (var xml = await HttpClient.Get(new HttpRequestOptions
- {
- Url = url,
- ResourcePool = FanArtResourcePool,
- CancellationToken = cancellationToken,
- EnableResponseCache = true
+ Url = url,
+ ResourcePool = FanArtResourcePool,
+ CancellationToken = cancellationToken,
+ EnableResponseCache = true
- }).ConfigureAwait(false))
- {
- doc.Load(xml);
- }
- }
- catch (HttpException)
+ }).ConfigureAwait(false))
{
+ doc.Load(xml);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -176,10 +172,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -199,16 +192,13 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
}
- SetLastRefreshed(item, DateTime.UtcNow);
+ SetLastRefreshed(item, DateTime.UtcNow, status);
return true;
}
diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
index 86a747000e..45c4eae7b8 100644
--- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
+++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs
@@ -1,5 +1,4 @@
-using System.Globalization;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
@@ -8,7 +7,7 @@ using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.Collections.Generic;
-using System.IO;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
@@ -118,22 +117,18 @@ namespace MediaBrowser.Controller.Providers.Music
var url = string.Format(FanArtBaseUrl, APIKey, item.GetProviderId(MetadataProviders.Musicbrainz));
var doc = new XmlDocument();
- try
+ var status = ProviderRefreshStatus.Success;
+
+ using (var xml = await HttpClient.Get(new HttpRequestOptions
{
- using (var xml = await HttpClient.Get(new HttpRequestOptions
- {
- Url = url,
- ResourcePool = FanArtResourcePool,
- CancellationToken = cancellationToken,
- EnableResponseCache = true
+ Url = url,
+ ResourcePool = FanArtResourcePool,
+ CancellationToken = cancellationToken,
+ EnableResponseCache = true
- }).ConfigureAwait(false))
- {
- doc.Load(xml);
- }
- }
- catch (HttpException)
+ }).ConfigureAwait(false))
{
+ doc.Load(xml);
}
cancellationToken.ThrowIfCancellationRequested();
@@ -157,10 +152,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -187,10 +179,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -216,10 +205,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -239,10 +225,7 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
@@ -263,16 +246,13 @@ namespace MediaBrowser.Controller.Providers.Music
}
catch (HttpException)
{
- }
- catch (IOException)
- {
-
+ status = ProviderRefreshStatus.CompletedWithErrors;
}
}
}
}
- SetLastRefreshed(item, DateTime.UtcNow);
+ SetLastRefreshed(item, DateTime.UtcNow, status);
return true;
}
}
diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index 522b2a4f87..664fe86da1 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -255,7 +255,7 @@ namespace MediaBrowser.Model.Configuration
DownloadMusicArtistImages = new ImageDownloadOptions();
DownloadMusicAlbumImages = new ImageDownloadOptions();
DownloadHDFanArt = true;
- MaxBackdrops = 4;
+ MaxBackdrops = 3;
SortReplaceCharacters = new[] { ".", "+", "%" };
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index a6422b525f..509a6fd7d3 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -95,6 +95,10 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
return name;
}());
+ self.deviceId = function () {
+ return deviceId;
+ };
+
self.encodeName = function (name) {
name = name.split('/').join('-');
diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config
index 3dde6a51ee..bfc7622a31 100644
--- a/MediaBrowser.WebDashboard/packages.config
+++ b/MediaBrowser.WebDashboard/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file