Fix Spotify playlist track counts to include external tracks

- Changed totalAvailableCount calculation to include both local and external matched tracks
- Updated logging to show breakdown of local vs external tracks
- This fixes Discover Weekly and other external-only playlists showing 0 tracks in clients

Now playlists with all external tracks will show correct track counts in Feishin and other clients.
This commit is contained in:
2026-02-04 23:35:10 -05:00
parent 4f74b34b9a
commit d045b33afd

View File

@@ -2843,21 +2843,22 @@ public class JellyfinController : ControllerBase
externalMatchedCount = matchedTracks.Count(t => t.MatchedSong != null && !t.MatchedSong.IsLocal); externalMatchedCount = matchedTracks.Count(t => t.MatchedSong != null && !t.MatchedSong.IsLocal);
} }
// Total available tracks = what's actually in Jellyfin (local + external matched) // Total available tracks = local tracks in Jellyfin + external matched tracks
// This is what clients should see as the track count // This represents what users will actually hear when playing the playlist
var totalAvailableCount = localTracksCount; var totalAvailableCount = localTracksCount + externalMatchedCount;
if (totalAvailableCount > 0) if (totalAvailableCount > 0)
{ {
// Update ChildCount to show actual available tracks // Update ChildCount to show actual available tracks
itemDict["ChildCount"] = totalAvailableCount; itemDict["ChildCount"] = totalAvailableCount;
modified = true; modified = true;
_logger.LogInformation("✓ Updated ChildCount for Spotify playlist {Name} to {Total} (actual tracks in Jellyfin)", _logger.LogInformation("✓ Updated ChildCount for Spotify playlist {Name} to {Total} ({Local} local + {External} external)",
playlistName, totalAvailableCount); playlistName, totalAvailableCount, localTracksCount, externalMatchedCount);
} }
else else
{ {
_logger.LogWarning("No tracks found in Jellyfin for {Name}", playlistName); _logger.LogWarning("No tracks found for {Name} ({Local} local + {External} external = {Total} total)",
playlistName, localTracksCount, externalMatchedCount, totalAvailableCount);
} }
} }
} }