mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 22:43:07 +03:00
Merge pull request #6358 from MrTimscampi/audio-people
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -27,7 +28,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
|
||||
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };
|
||||
|
||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||
private static readonly Regex _performerPattern = new (@"(?<name>.*) \((?<instrument>.*)\)");
|
||||
|
||||
private readonly CultureInfo _usCulture = new ("en-US");
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
||||
@@ -1128,7 +1131,26 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
}
|
||||
}
|
||||
|
||||
// Check for writer some music is tagged that way as alternative to composer/lyricist
|
||||
if (tags.TryGetValue("performer", out var performer) && !string.IsNullOrWhiteSpace(performer))
|
||||
{
|
||||
foreach (var person in Split(performer, false))
|
||||
{
|
||||
Match match = _performerPattern.Match(person);
|
||||
|
||||
// If the performer doesn't have any instrument/role associated, it won't match. In that case, chances are it's simply a band name, so we skip it.
|
||||
if (match.Success)
|
||||
{
|
||||
people.Add(new BaseItemPerson
|
||||
{
|
||||
Name = match.Groups["name"].Value,
|
||||
Type = PersonType.Actor,
|
||||
Role = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(match.Groups["instrument"].Value)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In cases where there isn't sufficient information as to which role a writer performed on a recording, tagging software uses the "writer" tag.
|
||||
if (tags.TryGetValue("writer", out var writer) && !string.IsNullOrWhiteSpace(writer))
|
||||
{
|
||||
foreach (var person in Split(writer, false))
|
||||
@@ -1137,6 +1159,38 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.TryGetValue("arranger", out var arranger) && !string.IsNullOrWhiteSpace(arranger))
|
||||
{
|
||||
foreach (var person in Split(arranger, false))
|
||||
{
|
||||
people.Add(new BaseItemPerson { Name = person, Type = PersonType.Arranger });
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.TryGetValue("engineer", out var engineer) && !string.IsNullOrWhiteSpace(engineer))
|
||||
{
|
||||
foreach (var person in Split(engineer, false))
|
||||
{
|
||||
people.Add(new BaseItemPerson { Name = person, Type = PersonType.Engineer });
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.TryGetValue("mixer", out var mixer) && !string.IsNullOrWhiteSpace(mixer))
|
||||
{
|
||||
foreach (var person in Split(mixer, false))
|
||||
{
|
||||
people.Add(new BaseItemPerson { Name = person, Type = PersonType.Mixer });
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.TryGetValue("remixer", out var remixer) && !string.IsNullOrWhiteSpace(remixer))
|
||||
{
|
||||
foreach (var person in Split(remixer, false))
|
||||
{
|
||||
people.Add(new BaseItemPerson { Name = person, Type = PersonType.Remixer });
|
||||
}
|
||||
}
|
||||
|
||||
audio.People = people.ToArray();
|
||||
|
||||
// Set album artist
|
||||
|
||||
Reference in New Issue
Block a user