mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix background service to use configured playlist names
This commit is contained in:
@@ -111,27 +111,15 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
|||||||
{
|
{
|
||||||
_playlistIdToName.Clear();
|
_playlistIdToName.Clear();
|
||||||
|
|
||||||
using var scope = _serviceProvider.CreateScope();
|
// Use configured playlist names instead of fetching from API
|
||||||
var proxyService = scope.ServiceProvider.GetRequiredService<JellyfinProxyService>();
|
for (int i = 0; i < _spotifySettings.Value.PlaylistIds.Count; i++)
|
||||||
|
{
|
||||||
|
var playlistId = _spotifySettings.Value.PlaylistIds[i];
|
||||||
|
var playlistName = i < _spotifySettings.Value.PlaylistNames.Count
|
||||||
|
? _spotifySettings.Value.PlaylistNames[i]
|
||||||
|
: playlistId; // Fallback to ID if name not configured
|
||||||
|
|
||||||
foreach (var playlistId in _spotifySettings.Value.PlaylistIds)
|
_playlistIdToName[playlistId] = playlistName;
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var playlistInfo = await proxyService.GetJsonAsync($"Items/{playlistId}", null, null);
|
|
||||||
if (playlistInfo != null && playlistInfo.RootElement.TryGetProperty("Name", out var nameElement))
|
|
||||||
{
|
|
||||||
var name = nameElement.GetString() ?? "";
|
|
||||||
if (!string.IsNullOrEmpty(name))
|
|
||||||
{
|
|
||||||
_playlistIdToName[playlistId] = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(ex, "Failed to get name for playlist {PlaylistId}", playlistId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user