mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
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:
@@ -1257,8 +1257,16 @@ public class JellyfinController : ControllerBase
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check if this is a Spotify playlist by fetching playlist info first
|
// Check if this is an external playlist (Deezer/Qobuz) first
|
||||||
if (_spotifySettings.Enabled && !playlistId.StartsWith("ext-") && !playlistId.StartsWith("playlist-"))
|
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
|
// Get playlist info from Jellyfin to check the name
|
||||||
var playlistInfo = await _proxyService.GetJsonAsync($"Items/{playlistId}", null, Request.Headers);
|
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
|
// Regular Jellyfin playlist - proxy through
|
||||||
var endpoint = $"Playlists/{playlistId}/Items";
|
var endpoint = $"Playlists/{playlistId}/Items";
|
||||||
if (Request.QueryString.HasValue)
|
if (Request.QueryString.HasValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user