mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-20 15:55:25 +03:00
Add some analyzers to MediaBrowser.MediaEncoding
This commit is contained in:
@@ -18,10 +18,19 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
{
|
||||
public class ProbeResultNormalizer
|
||||
{
|
||||
// When extracting subtitles, the maximum length to consider (to avoid invalid filenames)
|
||||
private const int MaxSubtitleDescriptionExtractionLength = 100;
|
||||
|
||||
private const string ArtistReplaceValue = " | ";
|
||||
|
||||
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
private List<string> _splitWhiteList = null;
|
||||
|
||||
public ProbeResultNormalizer(ILogger logger, ILocalizationManager localization)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -370,7 +379,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
|
||||
private List<NameValuePair> ReadValueArray(XmlReader reader)
|
||||
{
|
||||
|
||||
var pairs = new List<NameValuePair>();
|
||||
|
||||
reader.MoveToContent();
|
||||
@@ -951,50 +959,46 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
|
||||
private void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags)
|
||||
{
|
||||
var peoples = new List<BaseItemPerson>();
|
||||
var composer = FFProbeHelpers.GetDictionaryValue(tags, "composer");
|
||||
if (!string.IsNullOrWhiteSpace(composer))
|
||||
{
|
||||
var peoples = new List<BaseItemPerson>();
|
||||
foreach (var person in Split(composer, false))
|
||||
{
|
||||
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Composer });
|
||||
}
|
||||
|
||||
audio.People = peoples.ToArray();
|
||||
}
|
||||
|
||||
// var conductor = FFProbeHelpers.GetDictionaryValue(tags, "conductor");
|
||||
// if (!string.IsNullOrWhiteSpace(conductor))
|
||||
//{
|
||||
// foreach (var person in Split(conductor, false))
|
||||
// {
|
||||
// audio.People.Add(new BaseItemPerson { Name = person, Type = PersonType.Conductor });
|
||||
// }
|
||||
//}
|
||||
var conductor = FFProbeHelpers.GetDictionaryValue(tags, "conductor");
|
||||
if (!string.IsNullOrWhiteSpace(conductor))
|
||||
{
|
||||
foreach (var person in Split(conductor, false))
|
||||
{
|
||||
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Conductor });
|
||||
}
|
||||
}
|
||||
|
||||
// var lyricist = FFProbeHelpers.GetDictionaryValue(tags, "lyricist");
|
||||
// if (!string.IsNullOrWhiteSpace(lyricist))
|
||||
//{
|
||||
// foreach (var person in Split(lyricist, false))
|
||||
// {
|
||||
// audio.People.Add(new BaseItemPerson { Name = person, Type = PersonType.Lyricist });
|
||||
// }
|
||||
//}
|
||||
var lyricist = FFProbeHelpers.GetDictionaryValue(tags, "lyricist");
|
||||
if (!string.IsNullOrWhiteSpace(lyricist))
|
||||
{
|
||||
foreach (var person in Split(lyricist, false))
|
||||
{
|
||||
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Lyricist });
|
||||
}
|
||||
}
|
||||
|
||||
// Check for writer some music is tagged that way as alternative to composer/lyricist
|
||||
var writer = FFProbeHelpers.GetDictionaryValue(tags, "writer");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(writer))
|
||||
{
|
||||
var peoples = new List<BaseItemPerson>();
|
||||
foreach (var person in Split(writer, false))
|
||||
{
|
||||
peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Writer });
|
||||
}
|
||||
|
||||
audio.People = peoples.ToArray();
|
||||
}
|
||||
|
||||
audio.People = peoples.ToArray();
|
||||
audio.Album = FFProbeHelpers.GetDictionaryValue(tags, "album");
|
||||
|
||||
var artists = FFProbeHelpers.GetDictionaryValue(tags, "artists");
|
||||
@@ -1119,8 +1123,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
|
||||
}
|
||||
|
||||
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
|
||||
|
||||
/// <summary>
|
||||
/// Splits the specified val.
|
||||
/// </summary>
|
||||
@@ -1140,8 +1142,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
.Select(i => i.Trim());
|
||||
}
|
||||
|
||||
private const string ArtistReplaceValue = " | ";
|
||||
|
||||
private IEnumerable<string> SplitArtists(string val, char[] delimiters, bool splitFeaturing)
|
||||
{
|
||||
if (splitFeaturing)
|
||||
@@ -1171,9 +1171,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
return artistsFound;
|
||||
}
|
||||
|
||||
|
||||
private List<string> _splitWhiteList = null;
|
||||
|
||||
private IEnumerable<string> GetSplitWhitelist()
|
||||
{
|
||||
if (_splitWhiteList == null)
|
||||
@@ -1250,7 +1247,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the disc number, which is sometimes can be in the form of '1', or '1/3'
|
||||
/// Gets the disc number, which is sometimes can be in the form of '1', or '1/3'.
|
||||
/// </summary>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <param name="tagName">Name of the tag.</param>
|
||||
@@ -1296,8 +1293,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
return info;
|
||||
}
|
||||
|
||||
private const int MaxSubtitleDescriptionExtractionLength = 100; // When extracting subtitles, the maximum length to consider (to avoid invalid filenames)
|
||||
|
||||
private void FetchWtvInfo(MediaInfo video, InternalMediaInfoResult data)
|
||||
{
|
||||
if (data.Format == null || data.Format.Tags == null)
|
||||
@@ -1382,8 +1377,8 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
if (subtitle.Contains('/', StringComparison.Ordinal)) // It contains a episode number and season number
|
||||
{
|
||||
string[] numbers = subtitle.Split(' ');
|
||||
video.IndexNumber = int.Parse(numbers[0].Replace(".", "").Split('/')[0]);
|
||||
int totalEpisodesInSeason = int.Parse(numbers[0].Replace(".", "").Split('/')[1]);
|
||||
video.IndexNumber = int.Parse(numbers[0].Replace(".", string.Empty, StringComparison.Ordinal).Split('/')[0]);
|
||||
int totalEpisodesInSeason = int.Parse(numbers[0].Replace(".", string.Empty, StringComparison.Ordinal).Split('/')[1]);
|
||||
|
||||
description = string.Join(" ", numbers, 1, numbers.Length - 1).Trim(); // Skip the first, concatenate the rest, clean up spaces and save it
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user