refactor: optimize playlist interception order

- Check external playlists first (fast check)
- Only check Spotify if enabled (avoid extra API call)
- Fall back to regular Jellyfin playlists
- Maintains correct behavior for all playlist types
This commit is contained in:
2026-01-31 16:54:39 -05:00
parent c117fa41f6
commit 4ba2245876

View File

@@ -1257,8 +1257,16 @@ public class JellyfinController : ControllerBase
{
try
{
// Check if this is a Spotify playlist by fetching playlist info first
if (_spotifySettings.Enabled && !playlistId.StartsWith("ext-") && !playlistId.StartsWith("playlist-"))
// Check if this is an external playlist (Deezer/Qobuz) first
if (PlaylistIdHelper.IsExternalPlaylist(playlistId))
{
var (provider, externalId) = PlaylistIdHelper.ParsePlaylistId(playlistId);
var tracks = await _metadataService.GetPlaylistTracksAsync(provider, externalId);
return _responseBuilder.CreateItemsResponse(tracks);
}
// Only check for Spotify playlists if the feature is enabled
if (_spotifySettings.Enabled && !playlistId.StartsWith("ext-"))
{
// Get playlist info from Jellyfin to check the name
var playlistInfo = await _proxyService.GetJsonAsync($"Items/{playlistId}", null, Request.Headers);
@@ -1278,14 +1286,6 @@ public class JellyfinController : ControllerBase
}
}
// Check if this is an external playlist (Deezer/Qobuz)
if (PlaylistIdHelper.IsExternalPlaylist(playlistId))
{
var (provider, externalId) = PlaylistIdHelper.ParsePlaylistId(playlistId);
var tracks = await _metadataService.GetPlaylistTracksAsync(provider, externalId);
return _responseBuilder.CreateItemsResponse(tracks);
}
// Regular Jellyfin playlist - proxy through
var endpoint = $"Playlists/{playlistId}/Items";
if (Request.QueryString.HasValue)