diff --git a/scripts/audit-frontend-invokes.py b/scripts/audit-frontend-invokes.py index af01357f0..3af2af97e 100755 --- a/scripts/audit-frontend-invokes.py +++ b/scripts/audit-frontend-invokes.py @@ -22,7 +22,8 @@ def main() -> int: "src/routes/**/*.svelte", ] - invoke_pat = re.compile(r"invoke\(\s*['\"]([^'\"]+)['\"]") + # Match both invoke('cmd') and invoke('cmd') + invoke_pat = re.compile(r"invoke(?:<[^>]*>)?\(\s*['\"]([^'\"]+)['\"]") registrations_pat = re.compile(r"commands_v2::(v2_[A-Za-z0-9_]+|runtime_[A-Za-z0-9_]+)") front_paths = [] @@ -33,9 +34,9 @@ def main() -> int: for path in front_paths: text = load_text(path) rel = path.relative_to(root) - for idx, line in enumerate(text.splitlines(), 1): - for m in invoke_pat.finditer(line): - invokes.append((m.group(1), f"{rel}:{idx}")) + for m in invoke_pat.finditer(text): + line_no = text.count("\n", 0, m.start()) + 1 + invokes.append((m.group(1), f"{rel}:{line_no}")) lib_rs = load_text(root / "src-tauri/src/lib.rs") registered_v2 = set(registrations_pat.findall(lib_rs)) diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index 086688848..19c676888 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -88,6 +88,23 @@ pub struct AlsaPluginInfo { pub description: String, } +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct HardwareAudioStatus { + pub hardware_sample_rate: Option, + pub hardware_format: Option, + pub is_active: bool, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct DacCapabilities { + pub node_name: String, + pub sample_rates: Vec, + pub formats: Vec, + pub channels: Option, + pub description: Option, + pub error: Option, +} + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[serde(tag = "type", content = "content", rename_all = "lowercase")] pub enum V2MostPopularItem { @@ -1239,6 +1256,66 @@ pub fn v2_get_devices_for_backend( backend.enumerate_devices() } +#[tauri::command] +pub fn v2_get_hardware_audio_status( + state: State<'_, AppState>, +) -> Result { + let sample_rate = state.player.state.get_sample_rate(); + let bit_depth = state.player.state.get_bit_depth(); + let active = state.player.state.is_playing() && sample_rate > 0; + + let hardware_sample_rate = if sample_rate > 0 { Some(sample_rate) } else { None }; + let hardware_format = if sample_rate > 0 && bit_depth > 0 { + Some(format!("{}-bit / {:.1}kHz", bit_depth, sample_rate as f64 / 1000.0)) + } else { + None + }; + + Ok(HardwareAudioStatus { + hardware_sample_rate, + hardware_format, + is_active: active, + }) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_get_default_device_name( + backendType: AudioBackendType, +) -> Result, String> { + let backend = BackendManager::create_backend(backendType)?; + let devices = backend.enumerate_devices()?; + Ok(devices.into_iter().find(|d| d.is_default).map(|d| d.name)) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_query_dac_capabilities( + nodeName: String, +) -> Result { + let mut capabilities = DacCapabilities { + node_name: nodeName.clone(), + sample_rates: vec![44100, 48000, 88200, 96000, 176400, 192000], + formats: vec!["S16LE".to_string(), "S24LE".to_string(), "F32LE".to_string()], + channels: Some(2), + description: None, + error: None, + }; + + if let Ok(backend) = BackendManager::create_backend(AudioBackendType::PipeWire) { + if let Ok(devices) = backend.enumerate_devices() { + if let Some(device) = devices + .iter() + .find(|d| d.id == nodeName || d.name == nodeName) + { + capabilities.description = device.description.clone().or_else(|| Some(device.name.clone())); + } + } + } + + Ok(capabilities) +} + #[tauri::command] pub fn v2_get_alsa_plugins() -> Result, String> { Ok(vec![ @@ -1267,6 +1344,12 @@ pub fn v2_resolve_qobuz_link(url: String) -> Result Result { + Ok(format!("https://play.qobuz.com/track/{}", trackId)) +} + /// Check if QBZ is the default handler for qobuzapp:// links. #[tauri::command] pub fn v2_check_qobuzapp_handler() -> Result { @@ -1873,6 +1956,13 @@ pub async fn v2_cast_seek(position_secs: f64, state: State<'_, CastState>) -> Re state.chromecast.seek(position_secs).map_err(|e| e.to_string()) } +#[tauri::command] +pub async fn v2_cast_get_position( + state: State<'_, CastState>, +) -> Result { + state.chromecast.get_media_position().map_err(|e| e.to_string()) +} + #[tauri::command] pub async fn v2_cast_set_volume(volume: f32, state: State<'_, CastState>) -> Result<(), String> { state.chromecast.set_volume(volume).map_err(|e| e.to_string()) @@ -2013,6 +2103,15 @@ pub async fn v2_dlna_seek(position_secs: u64, state: State<'_, DlnaState>) -> Re conn.seek(position_secs).await.map_err(|e| e.to_string()) } +#[tauri::command] +pub async fn v2_dlna_get_position( + state: State<'_, DlnaState>, +) -> Result { + let connection = state.connection.lock().await; + let conn = connection.as_ref().ok_or_else(|| "Not connected".to_string())?; + conn.get_position_info().await.map_err(|e| e.to_string()) +} + #[tauri::command] pub async fn v2_dlna_set_volume(volume: f32, state: State<'_, DlnaState>) -> Result<(), String> { let mut connection = state.connection.lock().await; @@ -3437,6 +3536,91 @@ pub async fn v2_library_set_custom_artist_image( .map_err(|e| e.to_string()) } +#[tauri::command] +pub async fn v2_create_artist_radio( + artist_id: u64, + artist_name: String, + state: State<'_, AppState>, + blacklist_state: State<'_, BlacklistState>, + bridge: State<'_, CoreBridgeState>, + runtime: State<'_, RuntimeManagerState>, +) -> Result { + runtime + .manager() + .check_requirements(CommandRequirement::RequiresCoreBridgeAuth) + .await + .map_err(|e| e.to_string())?; + + let client = state.client.read().await.clone(); + + let session_id = tokio::task::spawn_blocking(move || -> Result { + let radio_db = crate::radio_engine::db::RadioDb::open_default()?; + let builder = crate::radio_engine::RadioPoolBuilder::new( + &radio_db, + &client, + crate::radio_engine::BuildRadioOptions::default(), + ); + let rt = tokio::runtime::Handle::current(); + let session = rt.block_on(builder.create_artist_radio(artist_id))?; + Ok(session.id) + }) + .await + .map_err(|e| format!("Radio task failed: {}", e))??; + + let client = state.client.read().await; + let track_ids = tokio::task::spawn_blocking({ + let session_id = session_id.clone(); + move || -> Result, String> { + let radio_db = crate::radio_engine::db::RadioDb::open_default()?; + let radio_engine = crate::radio_engine::RadioEngine::new(radio_db); + let mut ids = Vec::new(); + for _ in 0..60 { + match radio_engine.next_track(&session_id) { + Ok(radio_track) => ids.push(radio_track.track_id), + Err(_) => break, + } + } + Ok(ids.into_iter().take(50).collect()) + } + }) + .await + .map_err(|e| format!("Track generation task failed: {}", e))??; + + let mut tracks = Vec::new(); + for next_track_id in track_ids { + if let Ok(track) = client.get_track(next_track_id).await { + if let Some(ref performer) = track.performer { + if blacklist_state.is_blacklisted(performer.id) { + continue; + } + } + tracks.push(track); + } + } + + if tracks.is_empty() { + return Err("Failed to generate any radio tracks".to_string()); + } + + let queue_tracks: Vec = + tracks.iter().map(track_to_queue_track_from_api).collect(); + let bridge = bridge.get().await; + bridge.set_queue(queue_tracks, Some(0)).await; + + let queue_track_ids: Vec = tracks.iter().map(|t| t.id).collect(); + let context = PlaybackContext::new( + ContextType::Radio, + session_id.clone(), + artist_name, + ContentSource::Qobuz, + queue_track_ids, + 0, + ); + state.context.set_context(context); + + Ok(session_id) +} + #[tauri::command] pub async fn v2_create_track_radio( track_id: u64, @@ -4823,6 +5007,42 @@ pub async fn v2_get_playlist( bridge.get_playlist(playlistId).await.map_err(RuntimeError::Internal) } +#[tauri::command] +pub async fn v2_playlist_import_preview( + url: String, +) -> Result { + crate::playlist_import::preview_public_playlist(&url) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_playlist_import_execute( + url: String, + nameOverride: Option, + isPublic: bool, + app_state: State<'_, AppState>, + app: tauri::AppHandle, + runtime: State<'_, RuntimeManagerState>, +) -> Result { + runtime + .manager() + .check_requirements(CommandRequirement::RequiresUserSession) + .await?; + + let client = app_state.client.read().await; + crate::playlist_import::import_public_playlist( + &url, + &client, + nameOverride.as_deref(), + isPublic, + &app, + ) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())) +} + /// Get playlist metadata + track ids for progressive loading. #[tauri::command] #[allow(non_snake_case)] @@ -5903,6 +6123,87 @@ pub async fn v2_get_musician_appearances( }) } +#[tauri::command] +pub async fn v2_remote_metadata_search( + provider: String, + query: String, + artist: Option, + limit: Option, + musicbrainz_state: State<'_, MusicBrainzSharedState>, +) -> Result, RuntimeError> { + use crate::library::remote_metadata::{ + discogs_extended_to_search_result, musicbrainz_release_to_search_result, RemoteProvider, + }; + let provider = provider + .parse::() + .map_err(RuntimeError::Internal)?; + let max = limit.unwrap_or(10).clamp(1, 25); + + match provider { + RemoteProvider::MusicBrainz => { + let response = musicbrainz_state + .client + .search_releases_extended(&query, artist.as_deref().unwrap_or(""), None, max) + .await + .map_err(RuntimeError::Internal)?; + Ok(response + .releases + .iter() + .map(musicbrainz_release_to_search_result) + .collect()) + } + RemoteProvider::Discogs => { + let client = crate::discogs::DiscogsClient::new(); + let results = client + .search_releases(artist.as_deref().unwrap_or(""), &query, None, max) + .await + .map_err(RuntimeError::Internal)?; + Ok(results + .iter() + .map(discogs_extended_to_search_result) + .collect()) + } + } +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_remote_metadata_get_album( + provider: String, + providerId: String, + musicbrainz_state: State<'_, MusicBrainzSharedState>, +) -> Result { + use crate::library::remote_metadata::{ + discogs_full_to_metadata, musicbrainz_full_to_metadata, RemoteProvider, + }; + + let provider = provider + .parse::() + .map_err(RuntimeError::Internal)?; + + match provider { + RemoteProvider::MusicBrainz => { + let full = musicbrainz_state + .client + .get_release_with_tracks(&providerId) + .await + .map_err(RuntimeError::Internal)?; + Ok(musicbrainz_full_to_metadata(&full)) + } + RemoteProvider::Discogs => { + let id = providerId + .parse::() + .map_err(|e| RuntimeError::Internal(format!("Invalid Discogs release id: {}", e)))?; + let client = crate::discogs::DiscogsClient::new(); + let full = client + .get_release_metadata(id) + .await + .map_err(RuntimeError::Internal)?; + Ok(discogs_full_to_metadata(&full)) + } + } +} + #[tauri::command] pub async fn v2_musicbrainz_get_artist_relationships( mbid: String, @@ -6112,6 +6413,69 @@ pub async fn v2_listenbrainz_queue_listen( ).map_err(|e| RuntimeError::Internal(e)) } +#[tauri::command] +pub async fn v2_listenbrainz_flush_queue( + state: State<'_, ListenBrainzV2State>, + legacy_state: State<'_, crate::listenbrainz::ListenBrainzSharedState>, +) -> Result { + let queued = { + let cache_guard = legacy_state.cache.lock().await; + let cache = cache_guard + .as_ref() + .ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?; + cache.get_queued_listens(500).map_err(RuntimeError::Internal)? + }; + + if queued.is_empty() { + return Ok(0); + } + + let client = state.client.lock().await; + let mut sent_ids = Vec::new(); + + for listen in &queued { + let additional_info = qbz_integrations::listenbrainz::AdditionalInfo { + recording_mbid: listen.recording_mbid.clone(), + release_mbid: listen.release_mbid.clone(), + artist_mbids: listen.artist_mbids.clone(), + isrc: listen.isrc.clone(), + duration_ms: listen.duration_ms, + tracknumber: None, + media_player: "QBZ".to_string(), + media_player_version: env!("CARGO_PKG_VERSION").to_string(), + submission_client: "QBZ".to_string(), + submission_client_version: env!("CARGO_PKG_VERSION").to_string(), + }; + + if client + .submit_listen( + &listen.artist_name, + &listen.track_name, + listen.release_name.as_deref(), + listen.listened_at, + Some(additional_info), + ) + .await + .is_ok() + { + sent_ids.push(listen.id); + } + } + drop(client); + + if sent_ids.is_empty() { + return Ok(0); + } + + let cache_guard = legacy_state.cache.lock().await; + let cache = cache_guard + .as_ref() + .ok_or_else(|| RuntimeError::Internal("No active session - please log in".to_string()))?; + cache.mark_listens_sent(&sent_ids).map_err(RuntimeError::Internal)?; + + Ok(sent_ids.len() as u32) +} + // ==================== Playback Context Commands (V2) ==================== /// Get current playback context (V2) @@ -6579,6 +6943,239 @@ pub async fn v2_subscribe_playlist( .map_err(|e| format!("Failed to fetch created playlist: {}", e)) } +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_share_track_songlink( + isrc: Option, + url: String, + trackId: Option, + state: State<'_, AppState>, +) -> Result { + if let Some(code) = isrc.as_deref().map(str::trim).filter(|v| !v.is_empty()) { + return state + .songlink + .get_by_isrc(code) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())); + } + + let fallback_url = if let Some(id) = trackId { + format!("https://play.qobuz.com/track/{}", id) + } else { + url + }; + state + .songlink + .get_by_url(&fallback_url, crate::share::ContentType::Track) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_share_album_songlink( + upc: Option, + albumId: Option, + title: Option, + artist: Option, + state: State<'_, AppState>, +) -> Result { + let _ = (title, artist); + if let Some(code) = upc.as_deref().map(str::trim).filter(|v| !v.is_empty()) { + return state + .songlink + .get_by_upc(code) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())); + } + + let fallback_url = albumId + .map(|id| format!("https://play.qobuz.com/album/{}", id)) + .ok_or_else(|| RuntimeError::Internal("Missing UPC/albumId for song.link album lookup".to_string()))?; + state + .songlink + .get_by_url(&fallback_url, crate::share::ContentType::Album) + .await + .map_err(|e| RuntimeError::Internal(e.to_string())) +} + +#[tauri::command] +pub async fn v2_library_backfill_downloads( + state: State<'_, LibraryState>, + offline_cache_state: State<'_, crate::offline_cache::OfflineCacheState>, +) -> Result { + crate::library::commands::library_backfill_downloads(state, offline_cache_state) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_lyrics_get( + trackId: Option, + title: String, + artist: String, + album: Option, + durationSecs: Option, + state: State<'_, LyricsState>, +) -> Result, RuntimeError> { + crate::lyrics::commands::lyrics_get(trackId, title, artist, album, durationSecs, state) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_create_pending_playlist( + name: String, + description: Option, + isPublic: bool, + trackIds: Vec, + localTrackPaths: Vec, + state: State<'_, OfflineState>, +) -> Result { + crate::offline::commands::create_pending_playlist( + name, + description, + isPublic, + trackIds, + localTrackPaths, + state, + ) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +pub fn v2_get_pending_playlist_count( + state: State<'_, OfflineState>, +) -> Result { + crate::offline::commands::get_pending_playlist_count(state) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +pub fn v2_queue_scrobble( + artist: String, + track: String, + album: Option, + timestamp: i64, + state: State<'_, OfflineState>, +) -> Result { + crate::offline::commands::queue_scrobble(artist, track, album, timestamp, state) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_get_queued_scrobbles( + limit: Option, + state: State<'_, OfflineState>, +) -> Result, RuntimeError> { + crate::offline::commands::get_queued_scrobbles(limit, state) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +pub fn v2_get_queued_scrobble_count( + state: State<'_, OfflineState>, +) -> Result { + crate::offline::commands::get_queued_scrobble_count(state) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_cleanup_sent_scrobbles( + olderThanDays: Option, + state: State<'_, OfflineState>, +) -> Result { + crate::offline::commands::cleanup_sent_scrobbles(olderThanDays, state) + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_get_track_by_path( + filePath: String, + state: State<'_, LibraryState>, +) -> Result, RuntimeError> { + crate::library::commands::get_track_by_path(filePath, state) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub fn v2_check_network_path(path: String) -> Result { + Ok(crate::network::commands::check_network_path(path)) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_library_update_folder_settings( + id: i64, + alias: Option, + enabled: bool, + isNetwork: bool, + networkFsType: Option, + userOverrideNetwork: bool, + state: State<'_, LibraryState>, +) -> Result { + crate::library::commands::library_update_folder_settings( + id, + alias, + enabled, + isNetwork, + networkFsType, + userOverrideNetwork, + state, + ) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +pub async fn v2_discogs_has_credentials() -> Result { + crate::library::commands::discogs_has_credentials() + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_discogs_search_artwork( + artist: String, + album: String, + catalogNumber: Option, +) -> Result, RuntimeError> { + crate::library::commands::discogs_search_artwork(artist, album, catalogNumber) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_discogs_download_artwork( + imageUrl: String, + artist: String, + album: String, +) -> Result { + crate::library::commands::discogs_download_artwork(imageUrl, artist, album) + .await + .map_err(RuntimeError::Internal) +} + +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_check_album_fully_cached( + albumId: String, + cache_state: State<'_, crate::offline_cache::OfflineCacheState>, +) -> Result { + crate::offline_cache::commands::check_album_fully_cached(albumId, cache_state) + .await + .map_err(RuntimeError::Internal) +} + /// Shared helper: spawn the download task for a single track. /// Used by both v2_cache_track_for_offline (single) and v2_cache_tracks_batch_for_offline (batch). fn spawn_track_cache_download( diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 6952b9e14..0b7ed0798 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -676,6 +676,9 @@ pub fn run() { commands_v2::v2_get_cache_stats, commands_v2::v2_get_available_backends, commands_v2::v2_get_devices_for_backend, + commands_v2::v2_get_hardware_audio_status, + commands_v2::v2_get_default_device_name, + commands_v2::v2_query_dac_capabilities, commands_v2::v2_get_alsa_plugins, commands_v2::v2_plex_ping, commands_v2::v2_plex_get_music_sections, @@ -724,6 +727,7 @@ pub fn run() { commands_v2::v2_cast_pause, commands_v2::v2_cast_stop, commands_v2::v2_cast_seek, + commands_v2::v2_cast_get_position, commands_v2::v2_cast_set_volume, commands_v2::v2_dlna_start_discovery, commands_v2::v2_dlna_stop_discovery, @@ -735,6 +739,7 @@ pub fn run() { commands_v2::v2_dlna_pause, commands_v2::v2_dlna_stop, commands_v2::v2_dlna_seek, + commands_v2::v2_dlna_get_position, commands_v2::v2_dlna_set_volume, commands_v2::v2_airplay_start_discovery, commands_v2::v2_airplay_stop_discovery, @@ -779,6 +784,7 @@ pub fn run() { commands_v2::v2_playlist_get_tracks_with_local_copies, commands_v2::v2_library_set_album_artwork, commands_v2::v2_library_set_album_hidden, + commands_v2::v2_create_artist_radio, commands_v2::v2_create_track_radio, commands_v2::v2_delete_playlist_folder, commands_v2::v2_reorder_playlist_folders, @@ -904,6 +910,8 @@ pub fn run() { commands_v2::v2_remove_favorite, commands_v2::v2_get_user_playlists, commands_v2::v2_get_playlist, + commands_v2::v2_playlist_import_preview, + commands_v2::v2_playlist_import_execute, commands_v2::v2_get_playlist_track_ids, commands_v2::v2_check_playlist_duplicates, commands_v2::v2_add_tracks_to_playlist, @@ -964,6 +972,8 @@ pub fn run() { commands_v2::v2_musicbrainz_resolve_artist, commands_v2::v2_resolve_musician, commands_v2::v2_get_musician_appearances, + commands_v2::v2_remote_metadata_search, + commands_v2::v2_remote_metadata_get_album, commands_v2::v2_musicbrainz_get_artist_relationships, commands_v2::v2_lastfm_get_auth_url, commands_v2::v2_lastfm_complete_auth, @@ -973,6 +983,7 @@ pub fn run() { commands_v2::v2_lastfm_scrobble, commands_v2::v2_lastfm_set_session, commands_v2::v2_listenbrainz_queue_listen, + commands_v2::v2_listenbrainz_flush_queue, commands_v2::v2_get_playback_context, commands_v2::v2_set_playback_context, commands_v2::v2_clear_playback_context, @@ -996,6 +1007,23 @@ pub fn run() { commands_v2::v2_sync_cached_favorite_artists, commands_v2::v2_cache_favorite_artist, commands_v2::v2_uncache_favorite_artist, + commands_v2::v2_share_track_songlink, + commands_v2::v2_share_album_songlink, + commands_v2::v2_library_backfill_downloads, + commands_v2::v2_lyrics_get, + commands_v2::v2_create_pending_playlist, + commands_v2::v2_get_pending_playlist_count, + commands_v2::v2_queue_scrobble, + commands_v2::v2_get_queued_scrobbles, + commands_v2::v2_get_queued_scrobble_count, + commands_v2::v2_cleanup_sent_scrobbles, + commands_v2::v2_get_track_by_path, + commands_v2::v2_check_network_path, + commands_v2::v2_library_update_folder_settings, + commands_v2::v2_discogs_has_credentials, + commands_v2::v2_discogs_search_artwork, + commands_v2::v2_discogs_download_artwork, + commands_v2::v2_check_album_fully_cached, commands_v2::v2_purchases_get_all, commands_v2::v2_purchases_search, commands_v2::v2_purchases_get_album, @@ -1006,6 +1034,7 @@ pub fn run() { commands_v2::v2_purchases_remove_downloaded, commands_v2::v2_purchases_get_downloaded_track_ids, commands_v2::v2_resolve_qobuz_link, + commands_v2::v2_get_qobuz_track_url, commands_v2::v2_check_qobuzapp_handler, commands_v2::v2_register_qobuzapp_handler, commands_v2::v2_deregister_qobuzapp_handler, diff --git a/src/lib/components/AudioOutputBadges.svelte b/src/lib/components/AudioOutputBadges.svelte index 2a514c370..6e69cfa27 100644 --- a/src/lib/components/AudioOutputBadges.svelte +++ b/src/lib/components/AudioOutputBadges.svelte @@ -32,15 +32,11 @@ is_active: boolean; } - interface AlsaDevice { + interface BackendAudioDevice { id: string; name: string; description: string | null; is_default: boolean; - max_sample_rate: number | null; - supported_sample_rates: number[] | null; - device_bus: string | null; - is_hardware: boolean; } // Props @@ -55,7 +51,7 @@ let settings = $state(null); let outputStatus = $state(null); let pipewireSinks = $state([]); - let alsaDevices = $state([]); + let alsaDevices = $state([]); let hardwareStatus = $state(null); let isHovering = $state(false); @@ -82,7 +78,7 @@ return sink?.description ?? null; }); - // Get ALSA description for current device (fancy name from aplay -L) + // Get ALSA description for current device (backend-provided when available) const alsaDescription = $derived.by(() => { if (!currentDevice) return null; const device = alsaDevices.find(d => d.id === currentDevice || d.name === currentDevice); @@ -151,7 +147,7 @@ invoke('v2_get_audio_settings'), invoke('get_audio_output_status'), invoke('get_pipewire_sinks').catch(() => [] as PipewireSink[]), - invoke('get_alsa_devices').catch(() => [] as AlsaDevice[]), + invoke('v2_get_devices_for_backend', { backendType: 'Alsa' }).catch(() => [] as BackendAudioDevice[]), invoke('v2_get_hardware_audio_status').catch(() => null) ]); settings = settingsResult; diff --git a/src/lib/components/FolderSettingsModal.svelte b/src/lib/components/FolderSettingsModal.svelte index b2cdc20e5..732f6300d 100644 --- a/src/lib/components/FolderSettingsModal.svelte +++ b/src/lib/components/FolderSettingsModal.svelte @@ -81,7 +81,7 @@ // Detect if the current path is on a network mount async function detectNetworkStatus() { try { - const info = await invoke<{ isNetwork: boolean }>('check_network_path', { path: currentPath }); + const info = await invoke<{ isNetwork: boolean }>('v2_check_network_path', { path: currentPath }); detectedIsNetwork = info.isNetwork; } catch (err) { console.error('Failed to detect network status:', err); @@ -118,7 +118,7 @@ }); } - const updatedFolder = await invoke('library_update_folder_settings', { + const updatedFolder = await invoke('v2_library_update_folder_settings', { id: folder.id, alias: alias.trim() || null, enabled, diff --git a/src/lib/components/LocalLibraryTagEditorModal.svelte b/src/lib/components/LocalLibraryTagEditorModal.svelte index 7430702db..c389c27e7 100644 --- a/src/lib/components/LocalLibraryTagEditorModal.svelte +++ b/src/lib/components/LocalLibraryTagEditorModal.svelte @@ -163,7 +163,7 @@ selectedResult = null; try { - const results = await invoke('remote_metadata_search', { + const results = await invoke('v2_remote_metadata_search', { provider: remoteProvider, query: albumTitle.trim(), artist: albumArtist.trim() || null, @@ -186,7 +186,7 @@ remoteLoading = true; try { - const metadata = await invoke('remote_metadata_get_album', { + const metadata = await invoke('v2_remote_metadata_get_album', { provider: selectedResult.provider, providerId: selectedResult.provider_id }); diff --git a/src/lib/components/views/LabelView.svelte b/src/lib/components/views/LabelView.svelte index 11c833c68..90eae3156 100644 --- a/src/lib/components/views/LabelView.svelte +++ b/src/lib/components/views/LabelView.svelte @@ -80,7 +80,7 @@ image?: { small?: string; thumbnail?: string; large?: string }; albums?: { items: QobuzAlbum[]; total: number; offset: number; limit: number }; albums_count?: number; - }>('get_label', { labelId, limit: 100, offset: 0 }); + }>('v2_get_label', { labelId, limit: 100, offset: 0 }); label = { id: result.id, @@ -116,7 +116,7 @@ id: number; name: string; albums?: { items: QobuzAlbum[]; total: number; offset: number; limit: number }; - }>('get_label', { labelId, limit: 100, offset: albumsFetched }); + }>('v2_get_label', { labelId, limit: 100, offset: albumsFetched }); const newAlbums = result.albums?.items ?? []; albums = [...albums, ...newAlbums]; diff --git a/src/lib/components/views/LocalLibraryView.svelte b/src/lib/components/views/LocalLibraryView.svelte index 94d74b614..4975aa4eb 100644 --- a/src/lib/components/views/LocalLibraryView.svelte +++ b/src/lib/components/views/LocalLibraryView.svelte @@ -1074,7 +1074,7 @@ async function checkDiscogsCredentials() { try { - hasDiscogsCredentials = await invoke('discogs_has_credentials'); + hasDiscogsCredentials = await invoke('v2_discogs_has_credentials'); } catch { hasDiscogsCredentials = false; } @@ -2308,7 +2308,7 @@ discogsImagePage = 0; discogsFetchSuccessful = false; - const options = await invoke('discogs_search_artwork', { + const options = await invoke('v2_discogs_search_artwork', { artist: selectedAlbum.artist, album: selectedAlbum.title, catalogNumber: selectedAlbum.catalog_number || null @@ -2362,7 +2362,7 @@ if (selectedDiscogsImage) { console.log('Downloading Discogs artwork from:', selectedDiscogsImage); - const localPath = await invoke('discogs_download_artwork', { + const localPath = await invoke('v2_discogs_download_artwork', { imageUrl: selectedDiscogsImage, artist: selectedAlbum.artist, album: selectedAlbum.title diff --git a/src/lib/components/views/PlaylistDetailView.svelte b/src/lib/components/views/PlaylistDetailView.svelte index afd6a1040..68b2fe0f8 100644 --- a/src/lib/components/views/PlaylistDetailView.svelte +++ b/src/lib/components/views/PlaylistDetailView.svelte @@ -882,7 +882,7 @@ isCopying = true; try { - const newPlaylist = await invoke('subscribe_playlist', { playlistId: playlist.id }); + const newPlaylist = await invoke('v2_subscribe_playlist', { playlistId: playlist.id }); // Mark as copied so button disappears markPlaylistAsCopied(playlist.id); // Notify parent to refresh sidebar diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 182561bbd..76d2d3078 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -5,11 +5,10 @@ import { getCurrentWebview } from '@tauri-apps/api/webview'; import { writeText as copyToClipboard } from '@tauri-apps/plugin-clipboard-manager'; import { ask } from '@tauri-apps/plugin-dialog'; - import { ArrowLeft, ChevronRight, ChevronDown, ChevronUp, Loader2, Sun, Moon, SunMoon, HelpCircle, Ban, AlertTriangle, RefreshCw } from 'lucide-svelte'; + import { ArrowLeft, ChevronRight, ChevronDown, ChevronUp, Loader2, Sun, Moon, SunMoon, Ban, AlertTriangle, RefreshCw } from 'lucide-svelte'; import Toggle from '../Toggle.svelte'; import Dropdown from '../Dropdown.svelte'; import DeviceDropdown from '../DeviceDropdown.svelte'; - import AlsaUtilsHelpModal from '../AlsaUtilsHelpModal.svelte'; import DACSetupWizard from '../DACSetupWizard.svelte'; import RemoteControlSetupGuide from '../RemoteControlSetupGuide.svelte'; import LogsModal from '../LogsModal.svelte'; @@ -235,7 +234,6 @@ let legacyTracksCount = $state(0); // ALSA Utils help modal - let showAlsaUtilsHelpModal = $state(false); // DAC Setup Wizard modal let showDACWizardModal = $state(false); @@ -596,7 +594,7 @@ } // Device options based on selected backend (derived) - // For ALSA: use description from aplay -L if available, otherwise translate + // For ALSA: use backend-provided description if available, otherwise translate // For PipeWire/PulseAudio: names are already friendly let deviceOptions = $derived.by(() => { // First pass: generate display names @@ -2186,7 +2184,7 @@ if (settings.output_device) { const device = backendDevices.find(d => d.id === settings.output_device); if (device) { - // Use description from aplay -L if available (ALSA), otherwise translate + // Use backend-provided description if available (ALSA), otherwise translate outputDevice = (device.description && settings.backend_type === 'Alsa') ? device.description : (needsTranslation(device.name) ? getDevicePrettyName(device.name) : device.name); @@ -2671,7 +2669,7 @@ repaired_tracks: number; skipped_tracks: number; failed_tracks: string[]; - }>('library_backfill_downloads'); + }>('v2_library_backfill_downloads'); const message = `Repair complete!\n\nAdded: ${report.added_tracks}\nRepaired: ${report.repaired_tracks}\nSkipped: ${report.skipped_tracks}\nFailed: ${report.failed_tracks.length}`; @@ -3222,13 +3220,6 @@ > - {:else if selectedBackend === 'PipeWire'}