mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix authentication issue in UpdateSpotifyPlaylistCounts
- Added UserId parameter to playlist items request to avoid 401 Unauthorized - Fixed JsonElement casting issue that was causing InvalidCastException - This should resolve both the authentication error and the track count update Now Spotify playlists should show correct track counts without authentication errors.
This commit is contained in:
@@ -2812,14 +2812,24 @@ public class JellyfinController : ControllerBase
|
||||
}
|
||||
|
||||
// Only fetch from Jellyfin if we didn't get count from file cache
|
||||
if (!itemDict.ContainsKey("ChildCount") || (int)itemDict["ChildCount"]! == 0)
|
||||
if (!itemDict.ContainsKey("ChildCount") ||
|
||||
(itemDict["ChildCount"] is JsonElement childCountElement && childCountElement.GetInt32() == 0) ||
|
||||
(itemDict["ChildCount"] is int childCountInt && childCountInt == 0))
|
||||
{
|
||||
// Get local tracks count from Jellyfin
|
||||
var localTracksCount = 0;
|
||||
try
|
||||
{
|
||||
// Include UserId parameter to avoid 401 Unauthorized
|
||||
var userId = _settings.UserId;
|
||||
var playlistItemsUrl = $"Playlists/{playlistId}/Items";
|
||||
if (!string.IsNullOrEmpty(userId))
|
||||
{
|
||||
playlistItemsUrl += $"?UserId={userId}";
|
||||
}
|
||||
|
||||
var (localTracksResponse, _) = await _proxyService.GetJsonAsync(
|
||||
$"Playlists/{playlistId}/Items",
|
||||
playlistItemsUrl,
|
||||
null,
|
||||
Request.Headers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user