The Free Software Media System - Server Backend & API
Improve metadata probing to better support music videos
Maxr199824ac8a122339
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.csindex a87104cd67..22624dfd7d 100644--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs@@ -121,19 +121,67 @@ namespace MediaBrowser.MediaEncoding.Probing{info.Name = title;}+ else+ {+ title = FFProbeHelpers.GetDictionaryValue(tags, "title-eng");+ if (!string.IsNullOrWhiteSpace(title))+ {+ info.Name = title;+ }+ }++ var titleSort = FFProbeHelpers.GetDictionaryValue(tags, "titlesort");+ if (!string.IsNullOrWhiteSpace(titleSort))+ {+ info.ForcedSortName = titleSort;+ }info.IndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "episode_sort");info.ParentIndexNumber = FFProbeHelpers.GetDictionaryNumericValue(tags, "season_number");info.ShowName = FFProbeHelpers.GetDictionaryValue(tags, "show_name");info.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date");- // Several different forms of retaildate- info.PremiereDate = FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ??+ // Several different forms of retail/premiere date+ info.PremiereDate =+ FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ??FFProbeHelpers.GetDictionaryDateTime(tags, "retail date") ??FFProbeHelpers.GetDictionaryDateTime(tags, "retail_date") ??FFProbeHelpers.GetDictionaryDateTime(tags, "date_released") ??FFProbeHelpers.GetDictionaryDateTime(tags, "date");+ // Set common metadata for music (audio) and music videos (video)+ info.Album = FFProbeHelpers.GetDictionaryValue(tags, "album");++ var artists = FFProbeHelpers.GetDictionaryValue(tags, "artists");++ if (!string.IsNullOrWhiteSpace(artists))+ {+ info.Artists = SplitArtists(artists, new[] { '/', ';' }, false)+ .DistinctNames()+ .ToArray();+ }+ else+ {+ var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist");+ if (string.IsNullOrWhiteSpace(artist))+ {+ info.Artists = Array.Empty<string>();+ }+ else+ {+ info.Artists = SplitArtists(artist, _nameDelimiters, true)+ .DistinctNames()+ .ToArray();+ }+ }++ // If we don't have a ProductionYear try and get it from PremiereDate+ if (!info.ProductionYear.HasValue && info.PremiereDate.HasValue)+ {+ info.ProductionYear = info.PremiereDate.Value.Year;+ }++ // Set mediaType-specific metadataif (isAudio){SetAudioRuntimeTicks(data, info);@@ -1076,13 +1124,13 @@ namespace MediaBrowser.MediaEncoding.Probingprivate void SetAudioInfoFromTags(MediaInfo audio, Dictionary<string, string> tags){- var peoples = new List<BaseItemPerson>();+ var people = new List<BaseItemPerson>();var composer = FFProbeHelpers.GetDictionaryValue(tags, "composer");if (!string.IsNullOrWhiteSpace(composer)){foreach (var person in Split(composer, false)){- peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Composer });+ people.Add(new BaseItemPerson { Name = person, Type = PersonType.Composer });}}@@ -1091,7 +1139,7 @@ namespace MediaBrowser.MediaEncoding.Probing{foreach (var person in Split(conductor, false)){- peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Conductor });+ people.Add(new BaseItemPerson { Name = person, Type = PersonType.Conductor });}}@@ -1100,46 +1148,21 @@ namespace MediaBrowser.MediaEncoding.Probing{foreach (var person in Split(lyricist, false)){- peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Lyricist });+ people.Add(new BaseItemPerson { Name = person, Type = PersonType.Lyricist });}}// Check for writer some music is tagged that way as alternative to composer/lyricistvar writer = FFProbeHelpers.GetDictionaryValue(tags, "writer");-if (!string.IsNullOrWhiteSpace(writer)){foreach (var person in Split(writer, false)){- peoples.Add(new BaseItemPerson { Name = person, Type = PersonType.Writer });+ people.Add(new BaseItemPerson { Name = person, Type = PersonType.Writer });}}- audio.People = peoples.ToArray();- audio.Album = FFProbeHelpers.GetDictionaryValue(tags, "album");-- var artists = FFProbeHelpers.GetDictionaryValue(tags, "artists");-- if (!string.IsNullOrWhiteSpace(artists))- {- audio.Artists = SplitArtists(artists, new[] { '/', ';' }, false)- .DistinctNames()- .ToArray();- }- else- {- var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist");- if (string.IsNullOrWhiteSpace(artist))- {- audio.Artists = Array.Empty<string>();- }- else- {- audio.Artists = SplitArtists(artist, _nameDelimiters, true)- .DistinctNames()- .ToArray();- }- }+ audio.People = people.ToArray();var albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "albumartist");if (string.IsNullOrWhiteSpace(albumArtist))@@ -1174,12 +1197,6 @@ namespace MediaBrowser.MediaEncoding.Probing// Disc numberaudio.ParentIndexNumber = GetDictionaryDiscValue(tags, "disc");- // If we don't have a ProductionYear try and get it from PremiereDate- if (audio.PremiereDate.HasValue && !audio.ProductionYear.HasValue)- {- audio.ProductionYear = audio.PremiereDate.Value.ToLocalTime().Year;- }-// There's several values in tags may or may not be presentFetchStudios(audio, tags, "organization");FetchStudios(audio, tags, "ensemble");diff --git a/MediaBrowser.Model/MediaInfo/MediaInfo.cs b/MediaBrowser.Model/MediaInfo/MediaInfo.csindex a268a4fa66..453aeb028a 100644--- a/MediaBrowser.Model/MediaInfo/MediaInfo.cs+++ b/MediaBrowser.Model/MediaInfo/MediaInfo.cs@@ -51,6 +51,8 @@ namespace MediaBrowser.Model.MediaInfopublic string ShowName { get; set; }+ public string ForcedSortName { get; set; }+public int? IndexNumber { get; set; }public int? ParentIndexNumber { get; set; }diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.csindex 9454636669..cf271e7db1 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs@@ -111,6 +111,11 @@ namespace MediaBrowser.Providers.MediaInfoaudio.Name = data.Name;}+ if (!string.IsNullOrEmpty(data.ForcedSortName))+ {+ audio.ForcedSortName = data.ForcedSortName;+ }+if (audio.SupportsPeople && !audio.LockedFields.Contains(MetadataField.Cast)){var people = new List<PersonInfo>();diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.csindex 74849a5221..e7f9cf314f 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs@@ -394,6 +394,12 @@ namespace MediaBrowser.Providers.MediaInfo}}+ if (video is MusicVideo musicVideo)+ {+ musicVideo.Album = data.Album;+ musicVideo.Artists = data.Artists;+ }+if (data.ProductionYear.HasValue){if (!video.ProductionYear.HasValue || isFullRefresh)@@ -436,6 +442,11 @@ namespace MediaBrowser.Providers.MediaInfovideo.Name = data.Name;}}++ if (!string.IsNullOrWhiteSpace(data.ForcedSortName))+ {+ video.ForcedSortName = data.ForcedSortName;+ }}// If we don't have a ProductionYear try and get it from PremiereDate