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;
}
}