update MovieDb providers to search for images using all languages
This commit is contained in:
parent
22377f2516
commit
21ebd05a0e
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
{
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
|
||||
var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, language, cancellationToken).ConfigureAwait(false);
|
||||
var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, null, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (mainResult != null)
|
||||
{
|
||||
|
|
|
@ -169,11 +169,10 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
@ -196,7 +195,13 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
{
|
||||
if (!string.IsNullOrEmpty(language) && !string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
url = string.Format(GetCollectionInfo3, id, MovieDbSearch.ApiKey) + "&include_image_language=en,null&language=en";
|
||||
url = string.Format(GetCollectionInfo3, id, MovieDbSearch.ApiKey) + "&language=en";
|
||||
|
||||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
|
@ -239,15 +244,9 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
|
||||
private static string GetDataFilePath(IApplicationPaths appPaths, string tmdbId, string preferredLanguage)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(preferredLanguage))
|
||||
{
|
||||
throw new ArgumentNullException("preferredLanguage");
|
||||
}
|
||||
|
||||
var path = GetDataPath(appPaths, tmdbId);
|
||||
|
||||
var filename = string.Format("all-{0}.json",
|
||||
preferredLanguage);
|
||||
var filename = string.Format("all-{0}.json", preferredLanguage ?? string.Empty);
|
||||
|
||||
return Path.Combine(path, filename);
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
var results = await FetchImages((BaseItem)item, _jsonSerializer, cancellationToken).ConfigureAwait(false);
|
||||
var results = await FetchImages((BaseItem)item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (results == null)
|
||||
{
|
||||
|
@ -183,14 +183,13 @@ namespace MediaBrowser.Providers.Movies
|
|||
/// Fetches the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{MovieImages}.</returns>
|
||||
private async Task<MovieDbProvider.Images> FetchImages(BaseItem item, IJsonSerializer jsonSerializer,
|
||||
CancellationToken cancellationToken)
|
||||
private async Task<MovieDbProvider.Images> FetchImages(BaseItem item, string language, IJsonSerializer jsonSerializer, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tmdbId))
|
||||
{
|
||||
|
|
|
@ -226,10 +226,6 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
throw new ArgumentNullException("tmdbId");
|
||||
}
|
||||
if (string.IsNullOrEmpty(language))
|
||||
{
|
||||
throw new ArgumentNullException("language");
|
||||
}
|
||||
|
||||
var path = GetDataFilePath(tmdbId, language);
|
||||
|
||||
|
@ -253,15 +249,15 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
throw new ArgumentNullException("tmdbId");
|
||||
}
|
||||
if (string.IsNullOrEmpty(preferredLanguage))
|
||||
{
|
||||
throw new ArgumentNullException("preferredLanguage");
|
||||
}
|
||||
|
||||
var path = GetMovieDataPath(_configurationManager.ApplicationPaths, tmdbId);
|
||||
|
||||
var filename = string.Format("all-{0}.json",
|
||||
preferredLanguage);
|
||||
if (string.IsNullOrWhiteSpace(preferredLanguage))
|
||||
{
|
||||
preferredLanguage = "alllang";
|
||||
}
|
||||
|
||||
var filename = string.Format("all-{0}.json", preferredLanguage);
|
||||
|
||||
return Path.Combine(path, filename);
|
||||
}
|
||||
|
@ -298,11 +294,10 @@ namespace MediaBrowser.Providers.Movies
|
|||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
CompleteMovieData mainResult;
|
||||
|
||||
|
@ -348,7 +343,13 @@ namespace MediaBrowser.Providers.Movies
|
|||
{
|
||||
_logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English...");
|
||||
|
||||
url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en";
|
||||
url = string.Format(GetMovieInfo3, id, ApiKey) + "&language=en";
|
||||
|
||||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
var list = new List<RemoteImageInfo>();
|
||||
|
||||
var results = await FetchImages((BaseItem)item, _jsonSerializer, cancellationToken).ConfigureAwait(false);
|
||||
var results = await FetchImages((BaseItem)item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (results == null)
|
||||
{
|
||||
|
@ -146,14 +146,14 @@ namespace MediaBrowser.Providers.TV
|
|||
/// Fetches the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="language">The language.</param>
|
||||
/// <param name="jsonSerializer">The json serializer.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{MovieImages}.</returns>
|
||||
private async Task<MovieDbSeriesProvider.Images> FetchImages(BaseItem item, IJsonSerializer jsonSerializer,
|
||||
private async Task<MovieDbSeriesProvider.Images> FetchImages(BaseItem item, string language, IJsonSerializer jsonSerializer,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
|
||||
if (string.IsNullOrEmpty(tmdbId))
|
||||
{
|
||||
|
|
|
@ -302,11 +302,10 @@ namespace MediaBrowser.Providers.TV
|
|||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
@ -333,7 +332,13 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
_logger.Info("MovieDbSeriesProvider couldn't find meta for language " + language + ". Trying English...");
|
||||
|
||||
url = string.Format(GetTvInfo3, id, MovieDbProvider.ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en";
|
||||
url = string.Format(GetTvInfo3, id, MovieDbProvider.ApiKey) + "&language=en";
|
||||
|
||||
if (!string.IsNullOrEmpty(language))
|
||||
{
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
|
||||
}
|
||||
|
||||
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
|
@ -359,10 +364,6 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
throw new ArgumentNullException("tmdbId");
|
||||
}
|
||||
if (string.IsNullOrEmpty(language))
|
||||
{
|
||||
throw new ArgumentNullException("language");
|
||||
}
|
||||
|
||||
var path = GetDataFilePath(tmdbId, language);
|
||||
|
||||
|
@ -386,15 +387,10 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
throw new ArgumentNullException("tmdbId");
|
||||
}
|
||||
if (string.IsNullOrEmpty(preferredLanguage))
|
||||
{
|
||||
throw new ArgumentNullException("preferredLanguage");
|
||||
}
|
||||
|
||||
var path = GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId);
|
||||
|
||||
var filename = string.Format("series-{0}.json",
|
||||
preferredLanguage ?? string.Empty);
|
||||
var filename = string.Format("series-{0}.json", preferredLanguage ?? string.Empty);
|
||||
|
||||
return Path.Combine(path, filename);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user