|
|
|
@@ -1,3 +1,5 @@
|
|
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
@@ -16,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;
|
|
|
|
@@ -31,7 +42,8 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
var info = new MediaInfo
|
|
|
|
|
{
|
|
|
|
|
Path = path,
|
|
|
|
|
Protocol = protocol
|
|
|
|
|
Protocol = protocol,
|
|
|
|
|
VideoType = videoType
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FFProbeHelpers.NormalizeFFProbeResult(data);
|
|
|
|
@@ -368,7 +380,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
|
|
|
|
|
private List<NameValuePair> ReadValueArray(XmlReader reader)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var pairs = new List<NameValuePair>();
|
|
|
|
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
@@ -959,50 +970,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");
|
|
|
|
@@ -1127,8 +1134,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Splits the specified val.
|
|
|
|
|
/// </summary>
|
|
|
|
@@ -1139,7 +1144,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
{
|
|
|
|
|
// Only use the comma as a delimeter if there are no slashes or pipes.
|
|
|
|
|
// We want to be careful not to split names that have commas in them
|
|
|
|
|
var delimeter = !allowCommaDelimiter || _nameDelimiters.Any(i => val.IndexOf(i) != -1) ?
|
|
|
|
|
var delimeter = !allowCommaDelimiter || _nameDelimiters.Any(i => val.IndexOf(i, StringComparison.Ordinal) != -1) ?
|
|
|
|
|
_nameDelimiters :
|
|
|
|
|
new[] { ',' };
|
|
|
|
|
|
|
|
|
@@ -1148,8 +1153,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)
|
|
|
|
@@ -1179,9 +1182,6 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|
|
|
|
return artistsFound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<string> _splitWhiteList = null;
|
|
|
|
|
|
|
|
|
|
private IEnumerable<string> GetSplitWhitelist()
|
|
|
|
|
{
|
|
|
|
|
if (_splitWhiteList == null)
|
|
|
|
@@ -1258,7 +1258,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>
|
|
|
|
@@ -1304,8 +1304,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)
|
|
|
|
@@ -1390,8 +1388,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], CultureInfo.InvariantCulture);
|
|
|
|
|
int totalEpisodesInSeason = int.Parse(numbers[0].Replace(".", string.Empty, StringComparison.Ordinal).Split('/')[1], CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
|
|
description = string.Join(" ", numbers, 1, numbers.Length - 1).Trim(); // Skip the first, concatenate the rest, clean up spaces and save it
|
|
|
|
|
}
|
|
|
|
|