mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix Spotify playlist track counts in client responses
- Fixed UpdateSpotifyPlaylistCounts to use GetPlaylistByJellyfinId instead of GetPlaylistById - Fixed GetSpotifyPlaylistTracksOrderedAsync to use correct playlist config lookup - Added diagnostic logging for playlist config lookups - Removed test-websocket.html file This fixes the issue where Spotify playlists showed 0 tracks in playlist lists but worked correctly when accessed directly.
This commit is contained in:
@@ -2767,10 +2767,12 @@ public class JellyfinController : ControllerBase
|
|||||||
_logger.LogInformation("Found Spotify playlist: {Id}", playlistId);
|
_logger.LogInformation("Found Spotify playlist: {Id}", playlistId);
|
||||||
|
|
||||||
// This is a Spotify playlist - get the actual track count
|
// This is a Spotify playlist - get the actual track count
|
||||||
var playlistConfig = _spotifySettings.GetPlaylistById(playlistId);
|
var playlistConfig = _spotifySettings.GetPlaylistByJellyfinId(playlistId);
|
||||||
|
|
||||||
if (playlistConfig != null)
|
if (playlistConfig != null)
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("Found playlist config for Jellyfin ID {JellyfinId}: {Name} (Spotify ID: {SpotifyId})",
|
||||||
|
playlistId, playlistConfig.Name, playlistConfig.Id);
|
||||||
var playlistName = playlistConfig.Name;
|
var playlistName = playlistConfig.Name;
|
||||||
|
|
||||||
// Get matched external tracks (tracks that were successfully downloaded/matched)
|
// Get matched external tracks (tracks that were successfully downloaded/matched)
|
||||||
@@ -2859,6 +2861,10 @@ public class JellyfinController : ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("No playlist config found for Jellyfin ID {JellyfinId} - skipping count update", playlistId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3422,7 +3428,7 @@ public class JellyfinController : ControllerBase
|
|||||||
|
|
||||||
// Build final track list based on playlist configuration
|
// Build final track list based on playlist configuration
|
||||||
// Local tracks position is configurable per-playlist
|
// Local tracks position is configurable per-playlist
|
||||||
var playlistConfig = _spotifySettings.GetPlaylistById(playlistId);
|
var playlistConfig = _spotifySettings.GetPlaylistByJellyfinId(playlistId);
|
||||||
var localTracksPosition = playlistConfig?.LocalTracksPosition ?? LocalTracksPosition.First;
|
var localTracksPosition = playlistConfig?.LocalTracksPosition ?? LocalTracksPosition.First;
|
||||||
|
|
||||||
var finalTracks = new List<Song>();
|
var finalTracks = new List<Song>();
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>WebSocket Test</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Jellyfin WebSocket Test</h1>
|
|
||||||
<div id="status">Connecting...</div>
|
|
||||||
<div id="messages"></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Replace with your actual token and device ID
|
|
||||||
const token = "4d19e81402394d40a7e787222606b3c2";
|
|
||||||
const deviceId = "test-device-123";
|
|
||||||
|
|
||||||
// Connect to your proxy
|
|
||||||
const wsUrl = `ws://jfm.joshpatra.me/socket?api_key=${token}&deviceId=${deviceId}`;
|
|
||||||
|
|
||||||
console.log("Connecting to:", wsUrl);
|
|
||||||
document.getElementById('status').textContent = `Connecting to: ${wsUrl}`;
|
|
||||||
|
|
||||||
const ws = new WebSocket(wsUrl);
|
|
||||||
|
|
||||||
ws.onopen = () => {
|
|
||||||
console.log("✓ WebSocket connected!");
|
|
||||||
document.getElementById('status').textContent = "✓ Connected!";
|
|
||||||
document.getElementById('status').style.color = "green";
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.onmessage = (event) => {
|
|
||||||
console.log("Message received:", event.data);
|
|
||||||
const msgDiv = document.createElement('div');
|
|
||||||
msgDiv.textContent = `[${new Date().toLocaleTimeString()}] ${event.data}`;
|
|
||||||
document.getElementById('messages').appendChild(msgDiv);
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.onerror = (error) => {
|
|
||||||
console.error("WebSocket error:", error);
|
|
||||||
document.getElementById('status').textContent = "✗ Error!";
|
|
||||||
document.getElementById('status').style.color = "red";
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.onclose = (event) => {
|
|
||||||
console.log("WebSocket closed:", event.code, event.reason);
|
|
||||||
document.getElementById('status').textContent = `✗ Closed (${event.code})`;
|
|
||||||
document.getElementById('status').style.color = "orange";
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user