@@ -194,6 +200,7 @@
document.querySelector('#EnableLyrics').checked = config.EnableLyrics;
document.querySelector('#EnableGenres').checked = config.EnableGenres;
document.querySelector('#EnableLabels').checked = config.EnableLabels;
+ document.querySelector('#EnableCredits').checked = config.EnableCredits;
document.querySelector('#UseYandexAlbumName').checked = config.UseYandexAlbumName;
document.querySelector('#UseYandexYear').checked = config.UseYandexYear;
document.querySelector('#MatchThreshold').value = config.MatchThreshold;
@@ -225,6 +232,7 @@
config.EnableLyrics = document.querySelector('#EnableLyrics').checked;
config.EnableGenres = document.querySelector('#EnableGenres').checked;
config.EnableLabels = document.querySelector('#EnableLabels').checked;
+ config.EnableCredits = document.querySelector('#EnableCredits').checked;
config.UseYandexAlbumName = document.querySelector('#UseYandexAlbumName').checked;
config.UseYandexYear = document.querySelector('#UseYandexYear').checked;
config.MatchThreshold = parseFloat(document.querySelector('#MatchThreshold').value) || 0.72;
diff --git a/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj b/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj
index 3b4937a..1abcc7c 100644
--- a/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj
+++ b/Jellyfin.Plugin.YandexMusic/Jellyfin.Plugin.YandexMusic.csproj
@@ -1,9 +1,9 @@
- 1.0.0.3
- 1.0.0.3
- 1.0.0.3
+ 1.0.0.4
+ 1.0.0.4
+ 1.0.0.4
net10.0
Jellyfin.Plugin.YandexMusic
Jellyfin.Plugin.YandexMusic
diff --git a/Jellyfin.Plugin.YandexMusic/Providers/AlbumArtistCache.cs b/Jellyfin.Plugin.YandexMusic/Providers/AlbumArtistCache.cs
new file mode 100644
index 0000000..c790130
--- /dev/null
+++ b/Jellyfin.Plugin.YandexMusic/Providers/AlbumArtistCache.cs
@@ -0,0 +1,36 @@
+using System.Collections.Concurrent;
+
+namespace Jellyfin.Plugin.YandexMusic.Providers;
+
+///
+/// Album artists resolved by the song provider are not merged into Audio items by Jellyfin,
+/// so they are remembered here for the custom provider which runs right after the merge.
+///
+public static class AlbumArtistCache
+{
+ private static readonly ConcurrentDictionary Cache = new(StringComparer.Ordinal);
+
+ /// Stores album artists for an audio file path.
+ public static void Set(string? path, string[] artists)
+ {
+ if (string.IsNullOrWhiteSpace(path) || artists.Length == 0)
+ {
+ return;
+ }
+
+ Cache[path] = artists;
+ }
+
+ /// Gets album artists for an audio file path.
+ public static bool TryGet(string? path, out string[] artists)
+ {
+ if (!string.IsNullOrWhiteSpace(path) && Cache.TryGetValue(path, out var value))
+ {
+ artists = value;
+ return true;
+ }
+
+ artists = [];
+ return false;
+ }
+}
diff --git a/Jellyfin.Plugin.YandexMusic/Providers/Mapping.cs b/Jellyfin.Plugin.YandexMusic/Providers/Mapping.cs
index b7e48bc..3d933e2 100644
--- a/Jellyfin.Plugin.YandexMusic/Providers/Mapping.cs
+++ b/Jellyfin.Plugin.YandexMusic/Providers/Mapping.cs
@@ -26,6 +26,62 @@ public static class Mapping
private static PluginConfiguration Config => Plugin.Instance?.Configuration ?? new PluginConfiguration();
+ /// Adds composers and lyricists from Yandex track credits.
+ public static void AddCredits(
+ MediaBrowser.Controller.Providers.MetadataResult result,
+ IEnumerable 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
+ });
+ }
+ }
+
+ /// Returns credit values whose role matches the predicate.
+ public static IEnumerable CreditValues(IEnumerable credits, Func role)
+ => credits
+ .Where(c => role(c.Title) && !string.IsNullOrWhiteSpace(c.Value))
+ .Select(c => c.Value!);
+
+ /// Splits a credit value into individual names.
+ public static IEnumerable SplitNames(string value)
+ => value
+ .Split([',', ';'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
+ .Where(v => v.Length > 0);
+
+ /// Gets a value indicating whether the credit role is a composer.
+ public static bool IsComposerRole(string? title)
+ => title is not null
+ && (title.Contains("музык", StringComparison.OrdinalIgnoreCase)
+ || title.Contains("composer", StringComparison.OrdinalIgnoreCase)
+ || title.Equals("music", StringComparison.OrdinalIgnoreCase));
+
+ /// Gets a value indicating whether the credit role is a lyricist.
+ public static bool IsLyricistRole(string? title)
+ => title is not null
+ && (title.Contains("текст", StringComparison.OrdinalIgnoreCase)
+ || title.Contains("lyric", StringComparison.OrdinalIgnoreCase)
+ || title.Contains("writer", StringComparison.OrdinalIgnoreCase));
+
+ /// Gets a value indicating whether the credit role is a label.
+ public static bool IsLabelRole(string? title)
+ => title is not null
+ && (title.Contains("лейбл", StringComparison.OrdinalIgnoreCase)
+ || title.Contains("label", StringComparison.OrdinalIgnoreCase));
+
/// Gets a provider id from lookup info.
public static long? GetId(IReadOnlyDictionary? ids, string key)
{
diff --git a/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAlbumProvider.cs b/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAlbumProvider.cs
index b99a114..b1d2f29 100644
--- a/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAlbumProvider.cs
+++ b/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAlbumProvider.cs
@@ -71,7 +71,11 @@ public class YandexMusicAlbumProvider : IRemoteMetadataProvider a.Id > 0);
+ var albumArtistGenres = primaryGenreArtist is null
+ ? Array.Empty()
+ : await _client.GetArtistGenresAsync(primaryGenreArtist.Id, cancellationToken).ConfigureAwait(false);
+ item.Genres = await Mapping.GenresAsync(_client, album.Genre, albumArtistGenres, cancellationToken)
.ConfigureAwait(false);
var labels = Mapping.Labels(album);
diff --git a/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAudioCustomProvider.cs b/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAudioCustomProvider.cs
new file mode 100644
index 0000000..e01a80a
--- /dev/null
+++ b/Jellyfin.Plugin.YandexMusic/Providers/YandexMusicAudioCustomProvider.cs
@@ -0,0 +1,39 @@
+using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Entities;
+
+namespace Jellyfin.Plugin.YandexMusic.Providers;
+
+///
+/// Runs after the standard metadata merge and fixes fields that the Audio metadata service
+/// does not copy from a remote provider (most importantly AlbumArtists).
+///
+public class YandexMusicAudioCustomProvider : ICustomMetadataProvider