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
This commit is contained in:
1 parent
1de7c7830e
commit
12246ea2ad
2 files changed
+160
No files matched your search
@@ -4668,3 +4668,149 @@ pub async fn v2_plex_play_track(
|
|||||||
.map_err(|e| RuntimeError::Internal(e))
|
.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<Option<crate::library::PlaylistSettings>, 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<Vec<crate::library::PlaylistSettings>, 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<Option<crate::library::PlaylistStats>, 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<Vec<crate::library::PlaylistStats>, 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<crate::library::PlaylistStats, RuntimeError> {
|
||||||
|
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<Vec<u64>, 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<Vec<crate::library::LocalTrack>, 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<Vec<crate::library::PlaylistLocalTrack>, 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<Vec<(i64, bool, i32)>, 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<bool, RuntimeError> {
|
||||||
|
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<u64>,
|
||||||
|
state: tauri::State<'_, crate::library::commands::LibraryState>,
|
||||||
|
) -> Result<Vec<u64>, 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<crate::playlist_import::ImportPlaylist, RuntimeError> {
|
||||||
|
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<String>,
|
||||||
|
isPublic: Option<bool>,
|
||||||
|
state: tauri::State<'_, crate::AppState>,
|
||||||
|
) -> Result<crate::playlist_import::ImportSummary, RuntimeError> {
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1393,6 +1393,20 @@ pub fn run() {
|
|||||||
commands_v2::v2_plex_cache_get_tracks_needing_hydration,
|
commands_v2::v2_plex_cache_get_tracks_needing_hydration,
|
||||||
commands_v2::v2_plex_cache_clear,
|
commands_v2::v2_plex_cache_clear,
|
||||||
commands_v2::v2_plex_play_track,
|
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!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|||||||
Reference in new issue
Block a user