mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix lyrics cache key mismatch between prefetch and lookup
Use same artist format (comma-separated) in prefetch as LrclibService to ensure cached lyrics are found during playback
This commit is contained in:
@@ -135,7 +135,9 @@ public class LyricsPrefetchService : BackgroundService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check if lyrics are already cached
|
// Check if lyrics are already cached
|
||||||
var cacheKey = $"lyrics:{track.PrimaryArtist}:{track.Title}:{track.Album}:{track.DurationMs / 1000}";
|
// Use same cache key format as LrclibService: join all artists with ", "
|
||||||
|
var artistName = string.Join(", ", track.Artists);
|
||||||
|
var cacheKey = $"lyrics:{artistName}:{track.Title}:{track.Album}:{track.DurationMs / 1000}";
|
||||||
var existingLyrics = await _cache.GetStringAsync(cacheKey);
|
var existingLyrics = await _cache.GetStringAsync(cacheKey);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(existingLyrics))
|
if (!string.IsNullOrEmpty(existingLyrics))
|
||||||
@@ -154,7 +156,8 @@ public class LyricsPrefetchService : BackgroundService
|
|||||||
track.PrimaryArtist, track.Title);
|
track.PrimaryArtist, track.Title);
|
||||||
|
|
||||||
// Remove any previously cached LRCLib lyrics for this track
|
// Remove any previously cached LRCLib lyrics for this track
|
||||||
await RemoveCachedLyricsAsync(track.PrimaryArtist, track.Title, track.Album, track.DurationMs / 1000);
|
var artistNameForRemoval = string.Join(", ", track.Artists);
|
||||||
|
await RemoveCachedLyricsAsync(artistNameForRemoval, track.Title, track.Album, track.DurationMs / 1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +175,8 @@ public class LyricsPrefetchService : BackgroundService
|
|||||||
track.PrimaryArtist, track.Title, !string.IsNullOrEmpty(lyrics.SyncedLyrics));
|
track.PrimaryArtist, track.Title, !string.IsNullOrEmpty(lyrics.SyncedLyrics));
|
||||||
|
|
||||||
// Save to file cache
|
// Save to file cache
|
||||||
await SaveLyricsToFileAsync(track.PrimaryArtist, track.Title, track.Album, track.DurationMs / 1000, lyrics);
|
var artistNameForSave = string.Join(", ", track.Artists);
|
||||||
|
await SaveLyricsToFileAsync(artistNameForSave, track.Title, track.Album, track.DurationMs / 1000, lyrics);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user