Merge pull request #5696 from Maxr1998/fix-music-video-metadata-probing

This commit is contained in:
Claus Vium
2021-05-27 10:20:22 +02:00
committed by GitHub
7 changed files with 206 additions and 41 deletions

View File

@@ -124,19 +124,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 metadata
if (isAudio)
{
SetAudioRuntimeTicks(data, info);
@@ -1079,13 +1127,13 @@ namespace MediaBrowser.MediaEncoding.Probing
private 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 });
}
}
@@ -1094,7 +1142,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 });
}
}
@@ -1103,46 +1151,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/lyricist
var 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))
@@ -1177,12 +1200,6 @@ namespace MediaBrowser.MediaEncoding.Probing
// Disc number
audio.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 present
FetchStudios(audio, tags, "organization");
FetchStudios(audio, tags, "ensemble");