From 12246ea2ad0e87a6548333a0e028ab530644d5dc Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 16 Feb 2026 02:28:33 -0600 Subject: [PATCH] feat(v2): add more playlist V2 command wrappers Add V2 wrappers for playlist commands: - get_settings, get_all_settings - get_stats, get_all_stats, increment_play_count - get_favorites, get_local_tracks, get_local_tracks_with_position - get_custom_order, has_custom_order, get_tracks_with_local_copies - import_preview, import_execute --- src-tauri/src/commands_v2.rs | 146 +++++++++++++++++++++++++++++++++++ src-tauri/src/lib.rs | 14 ++++ 2 files changed, 160 insertions(+) diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index 718781180..b7fb1eef9 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -4668,3 +4668,149 @@ pub async fn v2_plex_play_track( .map_err(|e| RuntimeError::Internal(e)) } +// ============================================================================ +// Playlist Additional V2 Commands +// ============================================================================ + +/// Get playlist settings (V2) +#[tauri::command] +pub async fn v2_playlist_get_settings( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_settings {}", playlistId); + crate::library::commands::playlist_get_settings(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get all playlist settings (V2) +#[tauri::command] +pub async fn v2_playlist_get_all_settings( + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_all_settings"); + crate::library::commands::playlist_get_all_settings(state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get playlist stats (V2) +#[tauri::command] +pub async fn v2_playlist_get_stats( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_stats {}", playlistId); + crate::library::commands::playlist_get_stats(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get all playlist stats (V2) +#[tauri::command] +pub async fn v2_playlist_get_all_stats( + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_all_stats"); + crate::library::commands::playlist_get_all_stats(state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Increment playlist play count (V2) +#[tauri::command] +pub async fn v2_playlist_increment_play_count( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result { + log::info!("[V2] playlist_increment_play_count {}", playlistId); + crate::library::commands::playlist_increment_play_count(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get favorite playlist IDs (V2) +#[tauri::command] +pub async fn v2_playlist_get_favorites( + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_favorites"); + crate::library::commands::playlist_get_favorites(state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get local tracks in playlist (V2) +#[tauri::command] +pub async fn v2_playlist_get_local_tracks( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_local_tracks {}", playlistId); + crate::library::commands::playlist_get_local_tracks(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get local tracks in playlist with positions (V2) +#[tauri::command] +pub async fn v2_playlist_get_local_tracks_with_position( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_local_tracks_with_position {}", playlistId); + crate::library::commands::playlist_get_local_tracks_with_position(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get playlist custom order (V2) +#[tauri::command] +pub async fn v2_playlist_get_custom_order( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_custom_order {}", playlistId); + crate::library::commands::playlist_get_custom_order(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Check if playlist has custom order (V2) +#[tauri::command] +pub async fn v2_playlist_has_custom_order( + playlistId: u64, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result { + log::info!("[V2] playlist_has_custom_order {}", playlistId); + crate::library::commands::playlist_has_custom_order(playlistId, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Get tracks with local copies (V2) +#[tauri::command] +pub async fn v2_playlist_get_tracks_with_local_copies( + trackIds: Vec, + state: tauri::State<'_, crate::library::commands::LibraryState>, +) -> Result, RuntimeError> { + log::info!("[V2] playlist_get_tracks_with_local_copies count={}", trackIds.len()); + crate::library::commands::playlist_get_tracks_with_local_copies(trackIds, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Playlist import preview (V2) +#[tauri::command] +pub async fn v2_playlist_import_preview( + url: String, +) -> Result { + log::info!("[V2] playlist_import_preview {}", url); + crate::commands::playlist_import::playlist_import_preview(url).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Playlist import execute (V2) +#[tauri::command] +pub async fn v2_playlist_import_execute( + app: tauri::AppHandle, + url: String, + nameOverride: Option, + isPublic: Option, + state: tauri::State<'_, crate::AppState>, +) -> Result { + log::info!("[V2] playlist_import_execute {}", url); + crate::commands::playlist_import::playlist_import_execute(app, url, nameOverride, isPublic, state).await + .map_err(|e| RuntimeError::Internal(e)) +} + diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 8ab16f371..be7fa5cd8 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1393,6 +1393,20 @@ pub fn run() { commands_v2::v2_plex_cache_get_tracks_needing_hydration, commands_v2::v2_plex_cache_clear, commands_v2::v2_plex_play_track, + // Playlist Additional V2 + commands_v2::v2_playlist_get_settings, + commands_v2::v2_playlist_get_all_settings, + commands_v2::v2_playlist_get_stats, + commands_v2::v2_playlist_get_all_stats, + commands_v2::v2_playlist_increment_play_count, + commands_v2::v2_playlist_get_favorites, + commands_v2::v2_playlist_get_local_tracks, + commands_v2::v2_playlist_get_local_tracks_with_position, + commands_v2::v2_playlist_get_custom_order, + commands_v2::v2_playlist_has_custom_order, + commands_v2::v2_playlist_get_tracks_with_local_copies, + commands_v2::v2_playlist_import_preview, + commands_v2::v2_playlist_import_execute, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");