fix language settings inheritance

This commit is contained in:
Luke Pulverenti 2015-02-14 22:36:07 -05:00
parent 26fec4f990
commit 18ff8aba74
8 changed files with 84 additions and 13 deletions

View File

@ -976,14 +976,21 @@ namespace MediaBrowser.Controller.Entities
lang = hasLang.PreferredMetadataLanguage;
}
if (string.IsNullOrEmpty(lang))
if (string.IsNullOrWhiteSpace(lang))
{
lang = Parents.OfType<IHasPreferredMetadataLanguage>()
.Select(i => i.PreferredMetadataLanguage)
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
if (string.IsNullOrEmpty(lang))
if (string.IsNullOrWhiteSpace(lang))
{
lang = LibraryManager.GetCollectionFolders(this)
.Select(i => i.PreferredMetadataLanguage)
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
if (string.IsNullOrWhiteSpace(lang))
{
lang = ConfigurationManager.Configuration.PreferredMetadataLanguage;
}
@ -1006,14 +1013,21 @@ namespace MediaBrowser.Controller.Entities
lang = hasLang.PreferredMetadataCountryCode;
}
if (string.IsNullOrEmpty(lang))
if (string.IsNullOrWhiteSpace(lang))
{
lang = Parents.OfType<IHasPreferredMetadataLanguage>()
.Select(i => i.PreferredMetadataCountryCode)
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
if (string.IsNullOrEmpty(lang))
if (string.IsNullOrWhiteSpace(lang))
{
lang = LibraryManager.GetCollectionFolders(this)
.Select(i => i.PreferredMetadataCountryCode)
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
if (string.IsNullOrWhiteSpace(lang))
{
lang = ConfigurationManager.Configuration.MetadataCountryCode;
}

View File

@ -1,7 +1,4 @@
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
@ -10,6 +7,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Entities.TV
{

View File

@ -393,5 +393,12 @@ namespace MediaBrowser.Controller.Library
/// <returns>IEnumerable&lt;Video&gt;.</returns>
IEnumerable<Video> FindExtras(BaseItem owner, List<FileSystemInfo> fileSystemChildren,
IDirectoryService directoryService);
/// <summary>
/// Gets the collection folders.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>IEnumerable&lt;Folder&gt;.</returns>
IEnumerable<Folder> GetCollectionFolders(BaseItem item);
}
}

View File

@ -294,6 +294,19 @@ namespace MediaBrowser.Controller.Providers
break;
}
case "CountryCode":
{
var val = reader.ReadElementContentAsString();
var hasLanguage = item as IHasPreferredMetadataLanguage;
if (hasLanguage != null)
{
hasLanguage.PreferredMetadataCountryCode = val;
}
break;
}
case "PlaceOfBirth":
{
var val = reader.ReadElementContentAsString();

View File

@ -421,6 +421,10 @@ namespace MediaBrowser.LocalMetadata.Savers
{
builder.Append("<Language>" + SecurityElement.Escape(hasLanguage.PreferredMetadataLanguage) + "</Language>");
}
if (!string.IsNullOrEmpty(hasLanguage.PreferredMetadataCountryCode))
{
builder.Append("<CountryCode>" + SecurityElement.Escape(hasLanguage.PreferredMetadataCountryCode) + "</CountryCode>");
}
}
// Use original runtime here, actual file runtime later in MediaInfo

View File

@ -401,7 +401,7 @@ namespace MediaBrowser.Server.Implementations.Library
}
catch (DirectoryNotFoundException)
{
}
catch (Exception ex)
{
@ -1489,6 +1489,23 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.RetrieveItem(id);
}
public IEnumerable<Folder> GetCollectionFolders(BaseItem item)
{
while (!(item.Parent is AggregateFolder) && item.Parent != null)
{
item = item.Parent;
}
if (item == null)
{
return new List<Folder>();
}
return GetUserRootFolder().Children
.OfType<Folder>()
.Where(i => string.Equals(i.Path, item.Path, StringComparison.OrdinalIgnoreCase) || i.PhysicalLocations.Contains(item.Path));
}
public string GetContentType(BaseItem item)
{
string configuredContentType = GetConfiguredContentType(item, false);
@ -1547,7 +1564,7 @@ namespace MediaBrowser.Server.Implementations.Library
}
return null;
}
private string GetTopFolderContentType(BaseItem item)
{
while (!(item.Parent is AggregateFolder) && item.Parent != null)
@ -1840,7 +1857,7 @@ namespace MediaBrowser.Server.Implementations.Library
options.VideoFileExtensions.Remove(".rar");
options.VideoFileExtensions.Remove(".zip");
}
return options;
}

View File

@ -350,6 +350,19 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
case "countrycode":
{
var val = reader.ReadElementContentAsString();
var hasLanguage = item as IHasPreferredMetadataLanguage;
if (hasLanguage != null)
{
hasLanguage.PreferredMetadataCountryCode = val;
}
break;
}
case "website":
{
var val = reader.ReadElementContentAsString();

View File

@ -589,6 +589,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
{
writer.WriteElementString("language", hasLanguage.PreferredMetadataLanguage);
}
if (!string.IsNullOrEmpty(hasLanguage.PreferredMetadataCountryCode))
{
writer.WriteElementString("countrycode", hasLanguage.PreferredMetadataCountryCode);
}
}
if (item.PremiereDate.HasValue && !(item is Episode))