feat: implement per-playlist cron scheduling with persistent cache

- Added Cronos package for cron expression parsing
- Each playlist now has independent cron schedule (default: 0 8 * * 1)
- Cache persists until next cron run, not just cache duration
- Prevents excess Spotify API calls - only refreshes on cron trigger
- Manual refresh still allowed with 5-minute cooldown
- Added 429 rate limit handling for user playlist fetching
- Added crontab.guru link to UI for easy schedule building
- Both SpotifyPlaylistFetcher and SpotifyTrackMatchingService use cron
- Automatic matching only runs when cron schedule triggers
This commit is contained in:
2026-02-09 14:23:23 -05:00
parent a37f7e0b1d
commit 6949f8aed4
5 changed files with 337 additions and 91 deletions

View File

@@ -1966,6 +1966,12 @@ public class AdminController : ControllerBase
var response = await _jellyfinHttpClient.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
{
_logger.LogWarning("Spotify rate limit hit (429) when fetching playlists");
return StatusCode(429, new { error = "Spotify rate limit exceeded. Please wait a moment and try again." });
}
_logger.LogWarning("Failed to fetch Spotify playlists: {StatusCode}", response.StatusCode);
break;
}