37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Collections.Concurrent;
|
|
|
|
namespace Jellyfin.Plugin.YandexMusic.Providers;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public static class AlbumArtistCache
|
|
{
|
|
private static readonly ConcurrentDictionary<string, string[]> Cache = new(StringComparer.Ordinal);
|
|
|
|
/// <summary>Stores album artists for an audio file path.</summary>
|
|
public static void Set(string? path, string[] artists)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path) || artists.Length == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Cache[path] = artists;
|
|
}
|
|
|
|
/// <summary>Gets album artists for an audio file path.</summary>
|
|
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;
|
|
}
|
|
}
|