Change subtitles DisplayTitle behavior

This commit is contained in:
redSpoutnik
2019-03-14 22:31:51 +01:00
parent 276428878e
commit 427688a0a0
5 changed files with 49 additions and 11 deletions

View File

@@ -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
@@ -141,22 +147,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,6 +234,7 @@ namespace MediaBrowser.Model.Entities
return null;
}
/*
private string AddLanguageIfNeeded(string title)
{
if (!string.IsNullOrEmpty(Language) &&
@@ -241,6 +256,7 @@ namespace MediaBrowser.Model.Entities
return false;
}
*/
public string NalLengthSize { get; set; }