diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index 133c58211..557e5ca38 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -4830,6 +4830,23 @@ pub async fn v2_library_get_all_custom_album_covers( db.get_all_custom_album_covers().map_err(|e| e.to_string()) } +#[tauri::command] +pub async fn v2_save_image_url_to_file( + url: String, + dest_path: String, +) -> Result<(), String> { + let response = reqwest::get(&url) + .await + .map_err(|e| format!("Failed to download image: {}", e))?; + let bytes = response + .bytes() + .await + .map_err(|e| format!("Failed to read image data: {}", e))?; + std::fs::write(&dest_path, &bytes) + .map_err(|e| format!("Failed to save image: {}", e))?; + Ok(()) +} + #[tauri::command] pub async fn v2_create_artist_radio( artist_id: u64, diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index fd6072138..cd345323a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1205,6 +1205,7 @@ pub fn run() { commands_v2::v2_library_set_custom_album_cover, commands_v2::v2_library_remove_custom_album_cover, commands_v2::v2_library_get_all_custom_album_covers, + commands_v2::v2_save_image_url_to_file, commands_v2::v2_show_track_notification, commands_v2::v2_subscribe_playlist, commands_v2::v2_cache_track_for_offline, diff --git a/src/lib/components/views/AlbumDetailView.svelte b/src/lib/components/views/AlbumDetailView.svelte index 58cdcad55..9887ad8e3 100644 --- a/src/lib/components/views/AlbumDetailView.svelte +++ b/src/lib/components/views/AlbumDetailView.svelte @@ -1,7 +1,15 @@