using System.Collections.Concurrent; namespace Jellyfin.Plugin.YandexMusic.Providers; /// /// Provider ids resolved by the song provider. Jellyfin keeps existing ids during a normal /// refresh, so a previously wrong match can stick; the custom provider applies the resolved ids. /// public static class ProviderIdCache { private static readonly ConcurrentDictionary Cache = new(StringComparer.Ordinal); /// Stores ids for an audio file path. public static void Set(string? path, string track, string? album, string? artist) { if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(track)) { return; } Cache[path] = (track, album, artist); } /// Gets ids for an audio file path. public static bool TryGet(string? path, out (string Track, string? Album, string? Artist) ids) { if (!string.IsNullOrWhiteSpace(path) && Cache.TryGetValue(path, out var value)) { ids = value; return true; } ids = default; return false; } }