Use embedded title for other track types

This commit is contained in:
Pika 2020-04-06 13:49:35 -04:00
parent 0cd7cd611e
commit 1cf31229d8

View file

@ -77,106 +77,121 @@ namespace MediaBrowser.Model.Entities
{ {
get get
{ {
if (Type == MediaStreamType.Audio) switch (Type)
{ {
//if (!string.IsNullOrEmpty(Title)) case MediaStreamType.Audio:
//{ {
// return AddLanguageIfNeeded(Title); var attributes = new List<string>();
//}
var attributes = new List<string>(); if (!string.IsNullOrEmpty(Language))
{
attributes.Add(StringHelper.FirstToUpper(Language));
}
if (!string.IsNullOrEmpty(Language)) if (!string.IsNullOrEmpty(Codec) && !string.Equals(Codec, "dca", StringComparison.OrdinalIgnoreCase))
{ {
attributes.Add(StringHelper.FirstToUpper(Language)); attributes.Add(AudioCodec.GetFriendlyName(Codec));
} }
if (!string.IsNullOrEmpty(Codec) && !string.Equals(Codec, "dca", StringComparison.OrdinalIgnoreCase)) else if (!string.IsNullOrEmpty(Profile) && !string.Equals(Profile, "lc", StringComparison.OrdinalIgnoreCase))
{ {
attributes.Add(AudioCodec.GetFriendlyName(Codec)); attributes.Add(Profile);
} }
else if (!string.IsNullOrEmpty(Profile) && !string.Equals(Profile, "lc", StringComparison.OrdinalIgnoreCase))
{ if (!string.IsNullOrEmpty(ChannelLayout))
attributes.Add(Profile); {
attributes.Add(ChannelLayout);
}
else if (Channels.HasValue)
{
attributes.Add(Channels.Value.ToString(CultureInfo.InvariantCulture) + " ch");
}
if (IsDefault)
{
attributes.Add(string.IsNullOrEmpty(localizedDefault) ? "Default" : localizedDefault);
}
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 string.Join(" ", attributes);
} }
if (!string.IsNullOrEmpty(ChannelLayout)) case MediaStreamType.Video:
{ {
attributes.Add(ChannelLayout); var attributes = new List<string>();
}
else if (Channels.HasValue) var resolutionText = GetResolutionText();
{
attributes.Add(Channels.Value.ToString(CultureInfo.InvariantCulture) + " ch"); if (!string.IsNullOrEmpty(resolutionText))
} {
if (IsDefault) attributes.Add(resolutionText);
{ }
attributes.Add("Default");
if (!string.IsNullOrEmpty(Codec))
{
attributes.Add(Codec.ToUpperInvariant());
}
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 string.Join(" ", attributes);
} }
return string.Join(" ", attributes); case MediaStreamType.Subtitle:
{
var attributes = new List<string>();
if (!string.IsNullOrEmpty(Language))
{
attributes.Add(StringHelper.FirstToUpper(Language));
}
else
{
attributes.Add(string.IsNullOrEmpty(localizedUndefined) ? "Und" : localizedUndefined);
}
if (IsDefault)
{
attributes.Add(string.IsNullOrEmpty(localizedDefault) ? "Default" : localizedDefault);
}
if (IsForced)
{
attributes.Add(string.IsNullOrEmpty(localizedForced) ? "Forced" : localizedForced);
}
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 string.Join(" - ", attributes.ToArray());
}
default:
return null;
} }
if (Type == MediaStreamType.Video)
{
var attributes = new List<string>();
var resolutionText = GetResolutionText();
if (!string.IsNullOrEmpty(resolutionText))
{
attributes.Add(resolutionText);
}
if (!string.IsNullOrEmpty(Codec))
{
attributes.Add(Codec.ToUpperInvariant());
}
return string.Join(" ", attributes);
}
if (Type == MediaStreamType.Subtitle)
{
var attributes = new List<string>();
if (!string.IsNullOrEmpty(Language))
{
attributes.Add(StringHelper.FirstToUpper(Language));
}
else
{
attributes.Add(string.IsNullOrEmpty(localizedUndefined) ? "Und" : localizedUndefined);
}
if (IsDefault)
{
attributes.Add(string.IsNullOrEmpty(localizedDefault) ? "Default" : localizedDefault);
}
if (IsForced)
{
attributes.Add(string.IsNullOrEmpty(localizedForced) ? "Forced" : localizedForced);
}
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 string.Join(" - ", attributes.ToArray());
}
if (Type == MediaStreamType.Video)
{
}
return null;
} }
} }