fix foreign language fallback for moviedb
This commit is contained in:
parent
50a346fe5a
commit
75a46393f0
|
@ -33,6 +33,11 @@ namespace MediaBrowser.Dlna.Server
|
|||
_serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
private bool AbsoluteUrls
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public string GetXml()
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
@ -86,7 +91,10 @@ namespace MediaBrowser.Dlna.Server
|
|||
builder.Append("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
|
||||
builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>");
|
||||
|
||||
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
|
||||
if (!AbsoluteUrls)
|
||||
{
|
||||
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_profile.SonyAggregationFlags))
|
||||
{
|
||||
|
@ -144,7 +152,11 @@ namespace MediaBrowser.Dlna.Server
|
|||
url = url.TrimStart('/');
|
||||
|
||||
url = "/dlna/" + _serverUdn + "/" + url;
|
||||
//url = _serverAddress.TrimEnd('/') + url;
|
||||
|
||||
if (AbsoluteUrls)
|
||||
{
|
||||
url = _serverAddress.TrimEnd('/') + url;
|
||||
}
|
||||
|
||||
return SecurityElement.Escape(url);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace MediaBrowser.Model.ApiClient
|
|||
var existing = list[index];
|
||||
|
||||
// Merge the data
|
||||
existing.IsOffline = user.IsOffline;
|
||||
existing.IsSignedInOffline = user.IsSignedInOffline;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4,6 +4,6 @@ namespace MediaBrowser.Model.ApiClient
|
|||
public class ServerUserInfo
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public bool IsOffline { get; set; }
|
||||
public bool IsSignedInOffline { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,14 @@ namespace MediaBrowser.Model.Dto
|
|||
/// </summary>
|
||||
/// <value>The server identifier.</value>
|
||||
public string ServerId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the server.
|
||||
/// This is not used by the server and is for client-side usage only.
|
||||
/// </summary>
|
||||
/// <value>The name of the server.</value>
|
||||
public string ServerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the connect user.
|
||||
/// </summary>
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace MediaBrowser.Providers.BoxSets
|
|||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(_localization, language);
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -263,7 +262,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
return Path.Combine(path, filename);
|
||||
}
|
||||
|
||||
public static string GetImageLanguagesParam(ILocalizationManager localization, string preferredLanguage)
|
||||
public static string GetImageLanguagesParam(string preferredLanguage)
|
||||
{
|
||||
var languages = new List<string>();
|
||||
|
||||
|
@ -277,18 +276,6 @@ namespace MediaBrowser.Providers.Movies
|
|||
languages.Add("en");
|
||||
}
|
||||
|
||||
var firstLetter = string.IsNullOrWhiteSpace(preferredLanguage)
|
||||
? string.Empty
|
||||
: preferredLanguage.Substring(0, 1);
|
||||
|
||||
var allLanguages = localization.GetCultures()
|
||||
.Select(i => i.TwoLetterISOLanguageName)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Where(i => !languages.Contains(i, StringComparer.OrdinalIgnoreCase) && i.StartsWith(firstLetter, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
//languages.AddRange(allLanguages);
|
||||
|
||||
return string.Join(",", languages.ToArray());
|
||||
}
|
||||
|
||||
|
@ -309,7 +296,7 @@ namespace MediaBrowser.Providers.Movies
|
|||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = GetImageLanguagesParam(_localization, language);
|
||||
var includeImageLanguageParam = GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
|
||||
|
@ -336,26 +323,29 @@ namespace MediaBrowser.Providers.Movies
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (mainResult != null && string.IsNullOrEmpty(mainResult.overview))
|
||||
// If the language preference isn't english, then have the overview fallback to english if it's blank
|
||||
if (mainResult != null &&
|
||||
string.IsNullOrEmpty(mainResult.overview) &&
|
||||
!string.IsNullOrEmpty(language) &&
|
||||
!string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(language) && !string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
||||
_logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English...");
|
||||
|
||||
url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en";
|
||||
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
_logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English...");
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
CacheMode = cacheMode,
|
||||
CacheLength = cacheLength
|
||||
|
||||
url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en";
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var englishResult = _jsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
CacheMode = cacheMode,
|
||||
CacheLength = cacheLength
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = _jsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
mainResult.overview = englishResult.overview;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace MediaBrowser.Providers.TV
|
|||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(_localization, language);
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ namespace MediaBrowser.Providers.TV
|
|||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(_localization, language);
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace MediaBrowser.Providers.TV
|
|||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await EnsureSeriesInfo(tmdbId, searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
||||
var dataFilePath = GetDataFilePath(tmdbId, searchInfo.MetadataLanguage);
|
||||
|
||||
var obj = _jsonSerializer.DeserializeFromFile<RootObject>(dataFilePath);
|
||||
|
@ -84,7 +84,7 @@ namespace MediaBrowser.Providers.TV
|
|||
{
|
||||
remoteResult.SetProviderId(MetadataProviders.Tvdb, obj.external_ids.tvdb_id.ToString(_usCulture));
|
||||
}
|
||||
|
||||
|
||||
return new[] { remoteResult };
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ namespace MediaBrowser.Providers.TV
|
|||
}
|
||||
|
||||
series.HomePageUrl = seriesInfo.homepage;
|
||||
|
||||
|
||||
series.RunTimeTicks = seriesInfo.episode_run_time.Select(i => TimeSpan.FromMinutes(i).Ticks).FirstOrDefault();
|
||||
|
||||
if (string.Equals(seriesInfo.status, "Ended", StringComparison.OrdinalIgnoreCase))
|
||||
|
@ -302,12 +302,14 @@ namespace MediaBrowser.Providers.TV
|
|||
url += string.Format("&language={0}", language);
|
||||
}
|
||||
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(_localization, language);
|
||||
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language);
|
||||
// Get images in english and with no language
|
||||
url += "&include_image_language=" + includeImageLanguageParam;
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
RootObject mainResult;
|
||||
|
||||
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -316,8 +318,36 @@ namespace MediaBrowser.Providers.TV
|
|||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
return _jsonSerializer.DeserializeFromStream<RootObject>(json);
|
||||
mainResult = _jsonSerializer.DeserializeFromStream<RootObject>(json);
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// If the language preference isn't english, then have the overview fallback to english if it's blank
|
||||
if (mainResult != null &&
|
||||
string.IsNullOrEmpty(mainResult.overview) &&
|
||||
!string.IsNullOrEmpty(language) &&
|
||||
!string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_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";
|
||||
|
||||
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = MovieDbProvider.AcceptHeader
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var englishResult = _jsonSerializer.DeserializeFromStream<RootObject>(json);
|
||||
|
||||
mainResult.overview = englishResult.overview;
|
||||
}
|
||||
}
|
||||
|
||||
return mainResult;
|
||||
}
|
||||
|
||||
private readonly Task _cachedTask = Task.FromResult(true);
|
||||
|
|
|
@ -412,6 +412,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
// Hash the pin with the device Id to create a unique result for this device
|
||||
dto.OfflinePassword = GetSha1String(offlinePasswordHash + deviceId);
|
||||
|
||||
dto.ServerName = _appHost.FriendlyName;
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user