diff --git a/MediaBrowser.Controller/Entities/AdultVideo.cs b/MediaBrowser.Controller/Entities/AdultVideo.cs
index 9bb0f8355..9d19b5d92 100644
--- a/MediaBrowser.Controller/Entities/AdultVideo.cs
+++ b/MediaBrowser.Controller/Entities/AdultVideo.cs
@@ -1,7 +1,8 @@
namespace MediaBrowser.Controller.Entities
{
- public class AdultVideo : Video
+ public class AdultVideo : Video, IHasPreferredMetadataLanguage
{
+ public string PreferredMetadataLanguage { get; set; }
}
}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index e713a014c..6e5024a45 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -956,6 +956,29 @@ namespace MediaBrowser.Controller.Entities
return Id.ToString();
}
+ ///
+ /// Gets the preferred metadata language.
+ ///
+ /// System.String.
+ public virtual string GetPreferredMetadataLanguage()
+ {
+ string lang = null;
+
+ var hasLang = this as IHasPreferredMetadataLanguage;
+
+ if (hasLang != null)
+ {
+ lang = hasLang.PreferredMetadataLanguage;
+ }
+
+ if (string.IsNullOrEmpty(lang))
+ {
+ lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
+ }
+
+ return lang;
+ }
+
///
/// Determines if a given user has access to this item
///
diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs
index b51e93690..e4e1ab39c 100644
--- a/MediaBrowser.Controller/Entities/Book.cs
+++ b/MediaBrowser.Controller/Entities/Book.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace MediaBrowser.Controller.Entities
{
- public class Book : BaseItem, IHasTags
+ public class Book : BaseItem, IHasTags, IHasPreferredMetadataLanguage
{
public override string MediaType
{
@@ -12,6 +12,7 @@ namespace MediaBrowser.Controller.Entities
return Model.Entities.MediaType.Book;
}
}
+
///
/// Gets or sets the tags.
///
@@ -20,6 +21,8 @@ namespace MediaBrowser.Controller.Entities
public string SeriesName { get; set; }
+ public string PreferredMetadataLanguage { get; set; }
+
///
///
///
diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs
index a32e0d2bf..ce5f720ef 100644
--- a/MediaBrowser.Controller/Entities/Game.cs
+++ b/MediaBrowser.Controller/Entities/Game.cs
@@ -5,13 +5,15 @@ using System.Collections.Generic;
namespace MediaBrowser.Controller.Entities
{
- public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasLanguage, IHasScreenshots
+ public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasLanguage, IHasScreenshots, IHasPreferredMetadataLanguage
{
public List SoundtrackIds { get; set; }
public List ThemeSongIds { get; set; }
public List ThemeVideoIds { get; set; }
+ public string PreferredMetadataLanguage { get; set; }
+
public Game()
{
MultiPartGameFiles = new List();
diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs
index 0fa49639b..53bc64194 100644
--- a/MediaBrowser.Controller/Entities/Genre.cs
+++ b/MediaBrowser.Controller/Entities/Genre.cs
@@ -1,5 +1,4 @@
using MediaBrowser.Model.Dto;
-using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs
index 005c2d261..d800acd9b 100644
--- a/MediaBrowser.Controller/Entities/IHasImages.cs
+++ b/MediaBrowser.Controller/Entities/IHasImages.cs
@@ -75,6 +75,12 @@ namespace MediaBrowser.Controller.Entities
///
/// The primary image path.
string PrimaryImagePath { get; set; }
+
+ ///
+ /// Gets the preferred metadata language.
+ ///
+ /// System.String.
+ string GetPreferredMetadataLanguage();
}
public static class HasImagesExtensions
diff --git a/MediaBrowser.Controller/Entities/IHasPreferredMetadataLanguage.cs b/MediaBrowser.Controller/Entities/IHasPreferredMetadataLanguage.cs
new file mode 100644
index 000000000..facf71829
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasPreferredMetadataLanguage.cs
@@ -0,0 +1,15 @@
+
+namespace MediaBrowser.Controller.Entities
+{
+ ///
+ /// Interface IHasPreferredMetadataLanguage
+ ///
+ public interface IHasPreferredMetadataLanguage
+ {
+ ///
+ /// Gets or sets the preferred metadata language.
+ ///
+ /// The preferred metadata language.
+ string PreferredMetadataLanguage { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index f9b6922a2..755f687ff 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities.Movies
///
/// Class BoxSet
///
- public class BoxSet : Folder, IHasTrailers, IHasTags
+ public class BoxSet : Folder, IHasTrailers, IHasTags, IHasPreferredMetadataLanguage
{
public BoxSet()
{
@@ -31,6 +31,8 @@ namespace MediaBrowser.Controller.Entities.Movies
/// The tags.
public List Tags { get; set; }
+ public string PreferredMetadataLanguage { get; set; }
+
protected override bool GetBlockUnratedValue(UserConfiguration config)
{
return config.BlockUnratedMovies;
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 2126fb0d0..34845c3c3 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities.Movies
///
/// Class Movie
///
- public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags
+ public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasThemeMedia, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage
{
public List SpecialFeatureIds { get; set; }
@@ -20,6 +20,8 @@ namespace MediaBrowser.Controller.Entities.Movies
public List ThemeSongIds { get; set; }
public List ThemeVideoIds { get; set; }
+
+ public string PreferredMetadataLanguage { get; set; }
public Movie()
{
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index 9c2cf0b70..8338f76db 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.TV
///
/// Class Series
///
- public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasTags
+ public class Series : Folder, IHasSoundtracks, IHasTrailers, IHasTags, IHasPreferredMetadataLanguage
{
public List SpecialFeatureIds { get; set; }
public List SoundtrackIds { get; set; }
@@ -223,5 +223,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
return config.BlockUnratedSeries;
}
+
+ public string PreferredMetadataLanguage { get; set; }
}
}
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index 8e3ad14b3..f746ae630 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -9,9 +9,11 @@ namespace MediaBrowser.Controller.Entities
///
/// Class Trailer
///
- public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasTaglines, IHasTags
+ public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage
{
public List SoundtrackIds { get; set; }
+
+ public string PreferredMetadataLanguage { get; set; }
public Trailer()
{
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 7a9a5e8d1..f0c7d3149 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -88,6 +88,7 @@
+
diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs
index 0690de5ce..5f097dbcc 100644
--- a/MediaBrowser.Model/Dto/BaseItemDto.cs
+++ b/MediaBrowser.Model/Dto/BaseItemDto.cs
@@ -88,7 +88,7 @@ namespace MediaBrowser.Model.Dto
///
/// The path.
public string Path { get; set; }
-
+
///
/// Gets or sets the official rating.
///
diff --git a/MediaBrowser.Providers/Movies/ManualFanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/ManualFanartMovieImageProvider.cs
index ec9f86919..fae8cd591 100644
--- a/MediaBrowser.Providers/Movies/ManualFanartMovieImageProvider.cs
+++ b/MediaBrowser.Providers/Movies/ManualFanartMovieImageProvider.cs
@@ -69,7 +69,7 @@ namespace MediaBrowser.Providers.Movies
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/Movies/ManualMovieDbImageProvider.cs b/MediaBrowser.Providers/Movies/ManualMovieDbImageProvider.cs
index d02ae5550..1cbbca9c7 100644
--- a/MediaBrowser.Providers/Movies/ManualMovieDbImageProvider.cs
+++ b/MediaBrowser.Providers/Movies/ManualMovieDbImageProvider.cs
@@ -87,7 +87,7 @@ namespace MediaBrowser.Providers.Movies
RatingType = RatingType.Score
}));
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
@@ -123,8 +123,6 @@ namespace MediaBrowser.Providers.Movies
/// IEnumerable{MovieDbProvider.Poster}.
private IEnumerable GetPosters(MovieDbProvider.Images images, IHasImages item)
{
- var language = _config.Configuration.PreferredMetadataLanguage;
-
return images.posters ?? new List();
}
diff --git a/MediaBrowser.Providers/Movies/ManualMovieDbPersonImageProvider.cs b/MediaBrowser.Providers/Movies/ManualMovieDbPersonImageProvider.cs
index 2ad540849..453284751 100644
--- a/MediaBrowser.Providers/Movies/ManualMovieDbPersonImageProvider.cs
+++ b/MediaBrowser.Providers/Movies/ManualMovieDbPersonImageProvider.cs
@@ -6,7 +6,6 @@ using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -65,13 +64,13 @@ namespace MediaBrowser.Providers.Movies
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
- return GetImages(images, tmdbImageUrl);
+ return GetImages(images, item.GetPreferredMetadataLanguage(), tmdbImageUrl);
}
return new List();
}
- private IEnumerable GetImages(MovieDbPersonProvider.Images images, string baseImageUrl)
+ private IEnumerable GetImages(MovieDbPersonProvider.Images images, string preferredLanguage, string baseImageUrl)
{
var list = new List();
@@ -88,7 +87,7 @@ namespace MediaBrowser.Providers.Movies
}));
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = preferredLanguage;
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs
index 950dd353c..b66dd95b5 100644
--- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs
+++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs
@@ -318,7 +318,7 @@ namespace MediaBrowser.Providers.Movies
var year = item.ProductionYear ?? yearInName;
Logger.Info("MovieDbProvider: Finding id for item: " + name);
- string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
+ var language = item.GetPreferredMetadataLanguage().ToLower();
//if we are a boxset - look at our first child
var boxset = item as BoxSet;
@@ -502,7 +502,7 @@ namespace MediaBrowser.Providers.Movies
{
// Id could be ImdbId or TmdbId
- var language = ConfigurationManager.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var dataFilePath = GetDataFilePath(item);
@@ -538,7 +538,7 @@ namespace MediaBrowser.Providers.Movies
if (isForcedRefresh || ConfigurationManager.Configuration.EnableTmdbUpdates || !HasAltMeta(item))
{
- dataFilePath = GetDataFilePath(item, tmdbId);
+ dataFilePath = GetDataFilePath(item, tmdbId, language);
if (!string.IsNullOrEmpty(dataFilePath))
{
@@ -555,17 +555,16 @@ namespace MediaBrowser.Providers.Movies
/// The id.
/// if set to true [is box set].
/// The data path.
+ /// The preferred metadata language.
/// The cancellation token.
/// Task.
- internal async Task DownloadMovieInfo(string id, bool isBoxSet, string dataPath, CancellationToken cancellationToken)
+ internal async Task DownloadMovieInfo(string id, bool isBoxSet, string dataPath, string preferredMetadataLanguage, CancellationToken cancellationToken)
{
- var language = ConfigurationManager.Configuration.PreferredMetadataLanguage;
-
- var mainResult = await FetchMainResult(id, isBoxSet, language, cancellationToken).ConfigureAwait(false);
+ var mainResult = await FetchMainResult(id, isBoxSet, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
if (mainResult == null) return;
- var dataFilePath = Path.Combine(dataPath, language + ".json");
+ var dataFilePath = Path.Combine(dataPath, preferredMetadataLanguage + ".json");
Directory.CreateDirectory(dataPath);
@@ -593,16 +592,14 @@ namespace MediaBrowser.Providers.Movies
return null;
}
- return GetDataFilePath(item, id);
+ return GetDataFilePath(item, id, item.GetPreferredMetadataLanguage());
}
- internal string GetDataFilePath(BaseItem item, string tmdbId)
+ internal string GetDataFilePath(BaseItem item, string tmdbId, string preferredLanguage)
{
- var language = ConfigurationManager.Configuration.PreferredMetadataLanguage;
-
var path = GetMovieDataPath(ConfigurationManager.ApplicationPaths, item is BoxSet, tmdbId);
- path = Path.Combine(path, language + ".json");
+ path = Path.Combine(path, preferredLanguage + ".json");
return path;
}
@@ -838,15 +835,17 @@ namespace MediaBrowser.Providers.Movies
// genres
// Movies get this from imdb
- if (movieData.genres != null && !movie.LockedFields.Contains(MetadataFields.Genres))
+ var genres = movieData.genres ?? new List();
+ if (!movie.LockedFields.Contains(MetadataFields.Genres))
{
// Only grab them if a boxset or there are no genres.
// For movies and trailers we'll use imdb via omdb
- if (!(movie is Movie) || movie.Genres.Count == 0)
+ // But omdb data is for english users only so fetch if language is not english
+ if (!(movie is Movie) || movie.Genres.Count == 0 || !string.Equals(movie.GetPreferredMetadataLanguage(), "en", StringComparison.OrdinalIgnoreCase))
{
movie.Genres.Clear();
- foreach (var genre in movieData.genres.Select(g => g.name))
+ foreach (var genre in genres.Select(g => g.name))
{
movie.AddGenre(genre);
}
diff --git a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
index cba6f7dd8..4fe77b123 100644
--- a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
+++ b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
@@ -2,7 +2,10 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
@@ -37,6 +40,7 @@ namespace MediaBrowser.Providers.Movies
private readonly IServerConfigurationManager _config;
private readonly IJsonSerializer _json;
private readonly IFileSystem _fileSystem;
+ private readonly ILibraryManager _libraryManager;
///
/// Initializes a new instance of the class.
@@ -45,13 +49,14 @@ namespace MediaBrowser.Providers.Movies
/// The HTTP client.
/// The config.
/// The json.
- public MovieUpdatesPreScanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IJsonSerializer json, IFileSystem fileSystem)
+ public MovieUpdatesPreScanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IJsonSerializer json, IFileSystem fileSystem, ILibraryManager libraryManager)
{
_logger = logger;
_httpClient = httpClient;
_config = config;
_json = json;
_fileSystem = fileSystem;
+ _libraryManager = libraryManager;
}
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
@@ -196,15 +201,30 @@ namespace MediaBrowser.Providers.Movies
var list = ids.ToList();
var numComplete = 0;
+ // Gather all movies into a lookup by tmdb id
+ var allMovies = _libraryManager.RootFolder.RecursiveChildren
+ .Where(i => i is Movie || i is Trailer)
+ .Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tmdb)))
+ .ToLookup(i => i.GetProviderId(MetadataProviders.Tmdb));
+
foreach (var id in list)
{
- try
+ // Find the preferred language(s) for the movie in the library
+ var languages = allMovies[id]
+ .Select(i => i.GetPreferredMetadataLanguage())
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+
+ foreach (var language in languages)
{
- await UpdateMovie(id, isBoxSet, moviesDataPath, cancellationToken).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error updating tmdb movie id {0}", ex, id);
+ try
+ {
+ await UpdateMovie(id, isBoxSet, moviesDataPath, language, cancellationToken).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ _logger.ErrorException("Error updating tmdb movie id {0}, language {1}", ex, id, language);
+ }
}
numComplete++;
@@ -222,17 +242,18 @@ namespace MediaBrowser.Providers.Movies
/// The id.
/// if set to true [is box set].
/// The data path.
+ /// The preferred metadata language.
/// The cancellation token.
/// Task.
- private Task UpdateMovie(string id, bool isBoxSet, string dataPath, CancellationToken cancellationToken)
+ private Task UpdateMovie(string id, bool isBoxSet, string dataPath, string preferredMetadataLanguage, CancellationToken cancellationToken)
{
- _logger.Info("Updating movie from tmdb " + id);
+ _logger.Info("Updating movie from tmdb " + id + ", language " + preferredMetadataLanguage);
var itemDataPath = Path.Combine(dataPath, id);
Directory.CreateDirectory(dataPath);
- return MovieDbProvider.Current.DownloadMovieInfo(id, isBoxSet, itemDataPath, cancellationToken);
+ return MovieDbProvider.Current.DownloadMovieInfo(id, isBoxSet, itemDataPath, preferredMetadataLanguage, cancellationToken);
}
class Result
diff --git a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
index 1c7264ceb..8940f1d49 100644
--- a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
+++ b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs
@@ -202,6 +202,14 @@ namespace MediaBrowser.Providers.Movies
private bool ShouldFetchGenres(BaseItem item)
{
+ var lang = item.GetPreferredMetadataLanguage();
+
+ // The data isn't localized and so can only be used for english users
+ if (!string.Equals(lang, "en", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
// Only fetch if other providers didn't get anything
if (item is Trailer)
{
diff --git a/MediaBrowser.Providers/Music/ManualFanartAlbumProvider.cs b/MediaBrowser.Providers/Music/ManualFanartAlbumProvider.cs
index 99e7212fc..5c923869f 100644
--- a/MediaBrowser.Providers/Music/ManualFanartAlbumProvider.cs
+++ b/MediaBrowser.Providers/Music/ManualFanartAlbumProvider.cs
@@ -76,7 +76,7 @@ namespace MediaBrowser.Providers.Music
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/Music/ManualFanartArtistProvider.cs b/MediaBrowser.Providers/Music/ManualFanartArtistProvider.cs
index 85209a0e1..ddf5064aa 100644
--- a/MediaBrowser.Providers/Music/ManualFanartArtistProvider.cs
+++ b/MediaBrowser.Providers/Music/ManualFanartArtistProvider.cs
@@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Music
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/TV/ManualFanartSeasonProvider.cs b/MediaBrowser.Providers/TV/ManualFanartSeasonProvider.cs
index 6132f1097..503c56d0d 100644
--- a/MediaBrowser.Providers/TV/ManualFanartSeasonProvider.cs
+++ b/MediaBrowser.Providers/TV/ManualFanartSeasonProvider.cs
@@ -75,7 +75,7 @@ namespace MediaBrowser.Providers.TV
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/TV/ManualFanartSeriesProvider.cs b/MediaBrowser.Providers/TV/ManualFanartSeriesProvider.cs
index 12f9d2247..6a80f720a 100644
--- a/MediaBrowser.Providers/TV/ManualFanartSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/ManualFanartSeriesProvider.cs
@@ -71,7 +71,7 @@ namespace MediaBrowser.Providers.TV
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
+ var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
diff --git a/MediaBrowser.Providers/TV/ManualTvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/ManualTvdbSeasonImageProvider.cs
index e0c8434ce..d9a6f6507 100644
--- a/MediaBrowser.Providers/TV/ManualTvdbSeasonImageProvider.cs
+++ b/MediaBrowser.Providers/TV/ManualTvdbSeasonImageProvider.cs
@@ -65,7 +65,7 @@ namespace MediaBrowser.Providers.TV
try
{
- var result = GetImages(path, season.IndexNumber.Value, cancellationToken);
+ var result = GetImages(path, item.GetPreferredMetadataLanguage(), season.IndexNumber.Value, cancellationToken);
return Task.FromResult(result);
}
@@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.TV
return Task.FromResult>(new RemoteImageInfo[] { });
}
- private IEnumerable GetImages(string xmlPath, int seasonNumber, CancellationToken cancellationToken)
+ private IEnumerable GetImages(string xmlPath, string preferredLanguage, int seasonNumber, CancellationToken cancellationToken)
{
var settings = new XmlReaderSettings
{
@@ -123,13 +123,11 @@ namespace MediaBrowser.Providers.TV
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
-
- var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
+ var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i =>
{
- if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
diff --git a/MediaBrowser.Providers/TV/ManualTvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/ManualTvdbSeriesImageProvider.cs
index 0b48ddb2b..644cad93b 100644
--- a/MediaBrowser.Providers/TV/ManualTvdbSeriesImageProvider.cs
+++ b/MediaBrowser.Providers/TV/ManualTvdbSeriesImageProvider.cs
@@ -64,7 +64,7 @@ namespace MediaBrowser.Providers.TV
try
{
- var result = GetImages(path, cancellationToken);
+ var result = GetImages(path, item.GetPreferredMetadataLanguage(), cancellationToken);
return Task.FromResult(result);
}
@@ -77,7 +77,7 @@ namespace MediaBrowser.Providers.TV
return Task.FromResult>(new RemoteImageInfo[] { });
}
- private IEnumerable GetImages(string xmlPath, CancellationToken cancellationToken)
+ private IEnumerable GetImages(string xmlPath, string preferredLanguage, CancellationToken cancellationToken)
{
var settings = new XmlReaderSettings
{
@@ -122,13 +122,11 @@ namespace MediaBrowser.Providers.TV
}
}
- var language = _config.Configuration.PreferredMetadataLanguage;
-
- var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
+ var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i =>
{
- if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
diff --git a/MediaBrowser.Providers/TV/TvdbPrescanTask.cs b/MediaBrowser.Providers/TV/TvdbPrescanTask.cs
index 1a7f8e10e..24d231192 100644
--- a/MediaBrowser.Providers/TV/TvdbPrescanTask.cs
+++ b/MediaBrowser.Providers/TV/TvdbPrescanTask.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
@@ -45,6 +46,7 @@ namespace MediaBrowser.Providers.TV
///
private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;
+ private readonly ILibraryManager _libraryManager;
///
/// Initializes a new instance of the class.
@@ -52,12 +54,13 @@ namespace MediaBrowser.Providers.TV
/// The logger.
/// The HTTP client.
/// The config.
- public TvdbPrescanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IFileSystem fileSystem)
+ public TvdbPrescanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IFileSystem fileSystem, ILibraryManager libraryManager)
{
_logger = logger;
_httpClient = httpClient;
_config = config;
_fileSystem = fileSystem;
+ _libraryManager = libraryManager;
}
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
@@ -273,19 +276,36 @@ namespace MediaBrowser.Providers.TV
var list = seriesIds.ToList();
var numComplete = 0;
+ // Gather all series into a lookup by tvdb id
+ var allSeries = _libraryManager.RootFolder.RecursiveChildren
+ .OfType()
+ .Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)))
+ .ToLookup(i => i.GetProviderId(MetadataProviders.Tvdb));
+
foreach (var seriesId in list)
{
- try
+ // Find the preferred language(s) for the movie in the library
+ var languages = allSeries[seriesId]
+ .Select(i => i.GetPreferredMetadataLanguage())
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList();
+
+ foreach (var language in languages)
{
- await UpdateSeries(seriesId, seriesDataPath, lastTvDbUpdateTime, cancellationToken).ConfigureAwait(false);
- }
- catch (HttpException ex)
- {
- // Already logged at lower levels, but don't fail the whole operation, unless timed out
- // We have to fail this to make it run again otherwise new episode data could potentially be missing
- if (ex.IsTimedOut)
+ try
{
- throw;
+ await UpdateSeries(seriesId, seriesDataPath, lastTvDbUpdateTime, language, cancellationToken).ConfigureAwait(false);
+ }
+ catch (HttpException ex)
+ {
+ _logger.ErrorException("Error updating tvdb series id {0}, language {1}", ex, seriesId, language);
+
+ // Already logged at lower levels, but don't fail the whole operation, unless timed out
+ // We have to fail this to make it run again otherwise new episode data could potentially be missing
+ if (ex.IsTimedOut)
+ {
+ throw;
+ }
}
}
@@ -304,17 +324,18 @@ namespace MediaBrowser.Providers.TV
/// The id.
/// The series data path.
/// The last tv db update time.
+ /// The preferred metadata language.
/// The cancellation token.
/// Task.
- private Task UpdateSeries(string id, string seriesDataPath, long? lastTvDbUpdateTime, CancellationToken cancellationToken)
+ private Task UpdateSeries(string id, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
{
- _logger.Info("Updating series " + id);
+ _logger.Info("Updating movie from tmdb " + id + ", language " + preferredMetadataLanguage);
seriesDataPath = Path.Combine(seriesDataPath, id);
Directory.CreateDirectory(seriesDataPath);
- return TvdbSeriesProvider.Current.DownloadSeriesZip(id, seriesDataPath, lastTvDbUpdateTime, cancellationToken);
+ return TvdbSeriesProvider.Current.DownloadSeriesZip(id, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
index 5691f885e..4df391e2a 100644
--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
@@ -248,13 +248,13 @@ namespace MediaBrowser.Providers.TV
.Select(Path.GetFileName)
.ToList();
- var seriesXmlFilename = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower() + ".xml";
+ var seriesXmlFilename = series.GetPreferredMetadataLanguage().ToLower() + ".xml";
// Only download if not already there
// The prescan task will take care of updates so we don't need to re-download here
if (!files.Contains("banners.xml", StringComparer.OrdinalIgnoreCase) || !files.Contains("actors.xml", StringComparer.OrdinalIgnoreCase) || !files.Contains(seriesXmlFilename, StringComparer.OrdinalIgnoreCase))
{
- await DownloadSeriesZip(seriesId, seriesDataPath, null, cancellationToken).ConfigureAwait(false);
+ await DownloadSeriesZip(seriesId, seriesDataPath, null, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
}
// Have to check this here since we prevent the normal enforcement through ProviderManager
@@ -285,11 +285,13 @@ namespace MediaBrowser.Providers.TV
///
/// The series id.
/// The series data path.
+ /// The last tv database update time.
+ /// The preferred metadata language.
/// The cancellation token.
/// Task.
- internal async Task DownloadSeriesZip(string seriesId, string seriesDataPath, long? lastTvDbUpdateTime, CancellationToken cancellationToken)
+ internal async Task DownloadSeriesZip(string seriesId, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
{
- var url = string.Format(SeriesGetZip, TVUtils.TvdbApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
+ var url = string.Format(SeriesGetZip, TVUtils.TvdbApiKey, seriesId, preferredMetadataLanguage);
using (var zipStream = await HttpClient.Get(new HttpRequestOptions
{
@@ -319,7 +321,7 @@ namespace MediaBrowser.Providers.TV
await SanitizeXmlFile(file).ConfigureAwait(false);
}
- await ExtractEpisodes(seriesDataPath, Path.Combine(seriesDataPath, ConfigurationManager.Configuration.PreferredMetadataLanguage + ".xml"), lastTvDbUpdateTime).ConfigureAwait(false);
+ await ExtractEpisodes(seriesDataPath, Path.Combine(seriesDataPath, preferredMetadataLanguage + ".xml"), lastTvDbUpdateTime).ConfigureAwait(false);
}
private void DeleteXmlFiles(string path)
@@ -852,7 +854,7 @@ namespace MediaBrowser.Providers.TV
if (!string.IsNullOrWhiteSpace(val))
{
// Only fill this in if there's no existing genres, because Imdb data from Omdb is preferred
- if (!item.LockedFields.Contains(MetadataFields.Genres) && (item.Genres.Count == 0 || !string.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, "en", StringComparison.OrdinalIgnoreCase)))
+ if (!item.LockedFields.Contains(MetadataFields.Genres) && (item.Genres.Count == 0 || !string.Equals(item.GetPreferredMetadataLanguage(), "en", StringComparison.OrdinalIgnoreCase)))
{
var vals = val
.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
index 18f55b477..e9c672151 100644
--- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
+++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
@@ -378,7 +378,7 @@ namespace MediaBrowser.Server.Implementations.Providers
providers = providers.Where(i => string.Equals(i.Name, providerName, StringComparison.OrdinalIgnoreCase));
}
- var preferredLanguage = ConfigurationManager.Configuration.PreferredMetadataLanguage;
+ var preferredLanguage = item.GetPreferredMetadataLanguage();
var tasks = providers.Select(i => Task.Run(async () =>
{
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index b4cf52bfc..4011d1b09 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -417,7 +417,6 @@ namespace MediaBrowser.WebDashboard.Api
var files = new[]
{
"thirdparty/jquerymobile-1.4.0/jquery.mobile-1.4.0.min.css",
- //"thirdparty/jqm-icon-pack-3.0/font-awesome/jqm-icon-pack-3.0.0-fa.css" + versionString,
"css/all.css" + versionString
};
@@ -561,6 +560,8 @@ namespace MediaBrowser.WebDashboard.Api
await AppendResource(memoryStream, "thirdparty/jquery-2.0.3.min.js", newLineBytes).ConfigureAwait(false);
await AppendResource(memoryStream, "thirdparty/jquerymobile-1.4.0/jquery.mobile-1.4.0.min.js", newLineBytes).ConfigureAwait(false);
+ //await AppendResource(memoryStream, "thirdparty/jquery.infinite-scroll-helper.min.js", newLineBytes).ConfigureAwait(false);
+
var versionString = string.Format("window.dashboardVersion='{0}';", _appHost.ApplicationVersion);
var versionBytes = Encoding.UTF8.GetBytes(versionString);
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index 5975c3c92..c51d9eccb 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -481,6 +481,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest