Release 1.0.0.4: album artists, credits, artist genres, maintenance task
This commit is contained in:
1 parent
84e3ea34c8
commit
0dbf427ce1
17 files changed
+332
-14
No files matched your search
@@ -26,6 +26,62 @@ public static class Mapping
|
||||
|
||||
private static PluginConfiguration Config => Plugin.Instance?.Configuration ?? new PluginConfiguration();
|
||||
|
||||
/// <summary>Adds composers and lyricists from Yandex track credits.</summary>
|
||||
public static void AddCredits(
|
||||
MediaBrowser.Controller.Providers.MetadataResult<MediaBrowser.Controller.Entities.Audio.Audio> result,
|
||||
IEnumerable<CreditDto> credits)
|
||||
{
|
||||
foreach (var name in CreditValues(credits, IsComposerRole).SelectMany(SplitNames))
|
||||
{
|
||||
result.AddPerson(new MediaBrowser.Controller.Entities.PersonInfo
|
||||
{
|
||||
Name = name,
|
||||
Type = Jellyfin.Data.Enums.PersonKind.Composer
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var name in CreditValues(credits, IsLyricistRole).SelectMany(SplitNames))
|
||||
{
|
||||
result.AddPerson(new MediaBrowser.Controller.Entities.PersonInfo
|
||||
{
|
||||
Name = name,
|
||||
Type = Jellyfin.Data.Enums.PersonKind.Lyricist
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns credit values whose role matches the predicate.</summary>
|
||||
public static IEnumerable<string> CreditValues(IEnumerable<CreditDto> credits, Func<string?, bool> role)
|
||||
=> credits
|
||||
.Where(c => role(c.Title) && !string.IsNullOrWhiteSpace(c.Value))
|
||||
.Select(c => c.Value!);
|
||||
|
||||
/// <summary>Splits a credit value into individual names.</summary>
|
||||
public static IEnumerable<string> SplitNames(string value)
|
||||
=> value
|
||||
.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.Where(v => v.Length > 0);
|
||||
|
||||
/// <summary>Gets a value indicating whether the credit role is a composer.</summary>
|
||||
public static bool IsComposerRole(string? title)
|
||||
=> title is not null
|
||||
&& (title.Contains("музык", StringComparison.OrdinalIgnoreCase)
|
||||
|| title.Contains("composer", StringComparison.OrdinalIgnoreCase)
|
||||
|| title.Equals("music", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>Gets a value indicating whether the credit role is a lyricist.</summary>
|
||||
public static bool IsLyricistRole(string? title)
|
||||
=> title is not null
|
||||
&& (title.Contains("текст", StringComparison.OrdinalIgnoreCase)
|
||||
|| title.Contains("lyric", StringComparison.OrdinalIgnoreCase)
|
||||
|| title.Contains("writer", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>Gets a value indicating whether the credit role is a label.</summary>
|
||||
public static bool IsLabelRole(string? title)
|
||||
=> title is not null
|
||||
&& (title.Contains("лейбл", StringComparison.OrdinalIgnoreCase)
|
||||
|| title.Contains("label", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>Gets a provider id from lookup info.</summary>
|
||||
public static long? GetId(IReadOnlyDictionary<string, string>? ids, string key)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user