diff --git a/src-tauri/src/commands/playlist.rs b/src-tauri/src/commands/playlist.rs index e7746de33..c6b904289 100644 --- a/src-tauri/src/commands/playlist.rs +++ b/src-tauri/src/commands/playlist.rs @@ -5,6 +5,7 @@ use tauri::State; use crate::api::models::{Playlist, PlaylistDuplicateResult, PlaylistWithTrackIds, SearchResultsPage, Track}; use crate::api::performers::{parse_performers, Performer}; +use crate::library::commands::LibraryState; use crate::AppState; /// Track info with parsed performers for display @@ -325,6 +326,7 @@ pub async fn get_current_user_id(state: State<'_, AppState>) -> Result, + library_state: State<'_, LibraryState>, ) -> Result { log::info!("Command: subscribe_playlist {}", playlist_id); @@ -366,7 +368,19 @@ pub async fn subscribe_playlist( .await .map_err(|e| format!("Failed to add tracks to new playlist: {}", e))?; - // 6. Return the new playlist with updated track count + // 6. Save the original playlist's image as custom artwork for the new playlist + if let Some(ref images) = source.images { + if let Some(image_url) = images.first() { + let db_guard = library_state.db.lock().await; + if let Some(ref db) = *db_guard { + if let Err(e) = db.update_playlist_artwork(new_playlist.id, Some(image_url)) { + log::warn!("Failed to save original playlist artwork: {}", e); + } + } + } + } + + // 7. Return the new playlist with updated track count Ok(Playlist { tracks_count: track_ids.len() as u32, ..new_playlist diff --git a/src/lib/components/views/PlaylistDetailView.svelte b/src/lib/components/views/PlaylistDetailView.svelte index ae370a784..0af8b7420 100644 --- a/src/lib/components/views/PlaylistDetailView.svelte +++ b/src/lib/components/views/PlaylistDetailView.svelte @@ -1363,10 +1363,17 @@ return `${mins} min`; } + function resolveArtworkPath(path: string): string { + if (path.startsWith('http://') || path.startsWith('https://')) { + return path; + } + return `asset://localhost/${encodeURIComponent(path)}`; + } + function getPlaylistImage(): string { - // Use custom artwork if set (convert to tauri asset URL) + // Use custom artwork if set (URL or local file path) if (customArtworkPath) { - return `asset://localhost/${encodeURIComponent(customArtworkPath)}`; + return resolveArtworkPath(customArtworkPath); } if (playlist?.images && playlist.images.length > 0) { return playlist.images[0]; @@ -1883,7 +1890,7 @@
{#if customArtworkPath}
- {playlist.name} + {playlist.name}