Merge pull request #1090 from redSpoutnik/subtitle-display-title
Set DisplayTitle for subtitles
This commit is contained in:
commit
e81a6adb95
|
@ -770,7 +770,7 @@ namespace Emby.Server.Implementations
|
|||
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
|
||||
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo);
|
||||
|
||||
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory);
|
||||
ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, LocalizationManager);
|
||||
serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
|
||||
|
||||
AuthenticationRepository = GetAuthenticationRepository();
|
||||
|
@ -870,7 +870,8 @@ namespace Emby.Server.Implementations
|
|||
() => SubtitleEncoder,
|
||||
() => MediaSourceManager,
|
||||
ProcessFactory,
|
||||
5000);
|
||||
5000,
|
||||
LocalizationManager);
|
||||
serviceCollection.AddSingleton(MediaEncoder);
|
||||
|
||||
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager);
|
||||
|
|
|
@ -22,6 +22,7 @@ using MediaBrowser.Controller.Persistence;
|
|||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
@ -55,6 +56,8 @@ namespace Emby.Server.Implementations.Data
|
|||
private readonly IServerConfigurationManager _config;
|
||||
private IServerApplicationHost _appHost;
|
||||
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
public IImageProcessor ImageProcessor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -64,7 +67,8 @@ namespace Emby.Server.Implementations.Data
|
|||
IServerConfigurationManager config,
|
||||
IServerApplicationHost appHost,
|
||||
IJsonSerializer jsonSerializer,
|
||||
ILoggerFactory loggerFactory)
|
||||
ILoggerFactory loggerFactory,
|
||||
ILocalizationManager localization)
|
||||
: base(loggerFactory.CreateLogger(nameof(SqliteItemRepository)))
|
||||
{
|
||||
if (config == null)
|
||||
|
@ -81,6 +85,7 @@ namespace Emby.Server.Implementations.Data
|
|||
_config = config;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_typeMapper = new TypeMapper();
|
||||
_localization = localization;
|
||||
|
||||
DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
|
||||
}
|
||||
|
@ -6187,6 +6192,12 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
|||
item.ColorTransfer = reader[34].ToString();
|
||||
}
|
||||
|
||||
if (item.Type == MediaStreamType.Subtitle){
|
||||
item.localizedUndefined = _localization.GetLocalizedString("Undefined");
|
||||
item.localizedDefault = _localization.GetLocalizedString("Default");
|
||||
item.localizedForced = _localization.GetLocalizedString("Forced");
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ using MediaBrowser.Model.Configuration;
|
|||
using MediaBrowser.Model.Diagnostics;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
@ -54,6 +55,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(1, 1);
|
||||
private readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
public MediaEncoder(
|
||||
ILoggerFactory loggerFactory,
|
||||
|
@ -64,7 +66,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
Func<ISubtitleEncoder> subtitleEncoder,
|
||||
Func<IMediaSourceManager> mediaSourceManager,
|
||||
IProcessFactory processFactory,
|
||||
int defaultImageExtractionTimeoutMs)
|
||||
int defaultImageExtractionTimeoutMs,
|
||||
ILocalizationManager localization)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger(nameof(MediaEncoder));
|
||||
_jsonSerializer = jsonSerializer;
|
||||
|
@ -74,6 +77,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
SubtitleEncoder = subtitleEncoder;
|
||||
_processFactory = processFactory;
|
||||
DefaultImageExtractionTimeoutMs = defaultImageExtractionTimeoutMs;
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -413,7 +417,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
}
|
||||
}
|
||||
|
||||
return new ProbeResultNormalizer(_logger, FileSystem).GetMediaInfo(result, videoType, isAudio, primaryPath, protocol);
|
||||
return new ProbeResultNormalizer(_logger, FileSystem, _localization).GetMediaInfo(result, videoType, isAudio, primaryPath, protocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -20,11 +21,13 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
public ProbeResultNormalizer(ILogger logger, IFileSystem fileSystem)
|
||||
public ProbeResultNormalizer(ILogger logger, IFileSystem fileSystem, ILocalizationManager localization)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_localization = localization;
|
||||
}
|
||||
|
||||
public MediaInfo GetMediaInfo(InternalMediaInfoResult data, VideoType? videoType, bool isAudio, string path, MediaProtocol protocol)
|
||||
|
@ -596,6 +599,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
{
|
||||
stream.Type = MediaStreamType.Subtitle;
|
||||
stream.Codec = NormalizeSubtitleCodec(stream.Codec);
|
||||
stream.localizedUndefined = _localization.GetLocalizedString("Undefined");
|
||||
stream.localizedDefault = _localization.GetLocalizedString("Default");
|
||||
stream.localizedForced = _localization.GetLocalizedString("Forced");
|
||||
}
|
||||
else if (string.Equals(streamInfo.codec_type, "video", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
|
@ -65,6 +67,10 @@ namespace MediaBrowser.Model.Entities
|
|||
}
|
||||
}
|
||||
|
||||
public string localizedUndefined { get; set; }
|
||||
public string localizedDefault { get; set; }
|
||||
public string localizedForced { get; set; }
|
||||
|
||||
public string DisplayTitle
|
||||
{
|
||||
get
|
||||
|
@ -128,10 +134,6 @@ namespace MediaBrowser.Model.Entities
|
|||
|
||||
if (Type == MediaStreamType.Subtitle)
|
||||
{
|
||||
//if (!string.IsNullOrEmpty(Title))
|
||||
//{
|
||||
// return AddLanguageIfNeeded(Title);
|
||||
//}
|
||||
|
||||
var attributes = new List<string>();
|
||||
|
||||
|
@ -141,22 +143,30 @@ namespace MediaBrowser.Model.Entities
|
|||
}
|
||||
else
|
||||
{
|
||||
attributes.Add("Und");
|
||||
attributes.Add(string.IsNullOrEmpty(localizedUndefined) ? "Und" : localizedUndefined);
|
||||
}
|
||||
|
||||
if (IsDefault)
|
||||
{
|
||||
attributes.Add("Default");
|
||||
attributes.Add(string.IsNullOrEmpty(localizedDefault) ? "Default" : localizedDefault);
|
||||
}
|
||||
|
||||
if (IsForced)
|
||||
{
|
||||
attributes.Add("Forced");
|
||||
attributes.Add(string.IsNullOrEmpty(localizedForced) ? "Forced" : localizedForced);
|
||||
}
|
||||
|
||||
string name = string.Join(" ", attributes.ToArray());
|
||||
if (!string.IsNullOrEmpty(Title))
|
||||
{
|
||||
return attributes.AsEnumerable()
|
||||
// keep Tags that are not already in Title
|
||||
.Where(tag => Title.IndexOf(tag, StringComparison.OrdinalIgnoreCase) == -1)
|
||||
// attributes concatenation, starting with Title
|
||||
.Aggregate(new StringBuilder(Title), (builder, attr) => builder.Append(" - ").Append(attr))
|
||||
.ToString();
|
||||
}
|
||||
|
||||
return name;
|
||||
return string.Join(" - ", attributes.ToArray());
|
||||
}
|
||||
|
||||
if (Type == MediaStreamType.Video)
|
||||
|
@ -220,28 +230,6 @@ namespace MediaBrowser.Model.Entities
|
|||
return null;
|
||||
}
|
||||
|
||||
private string AddLanguageIfNeeded(string title)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Language) &&
|
||||
!string.Equals(Language, "und", StringComparison.OrdinalIgnoreCase) &&
|
||||
!IsLanguageInTitle(title, Language))
|
||||
{
|
||||
title = StringHelper.FirstToUpper(Language) + " " + title;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
private bool IsLanguageInTitle(string title, string language)
|
||||
{
|
||||
if (title.IndexOf(Language, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string NalLengthSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user