diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index cd38b8ae8..718781180 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -4473,3 +4473,198 @@ pub fn v2_save_credentials( .map_err(|e| RuntimeError::Internal(e)) } +// ============================================================================ +// Plex V2 Commands +// ============================================================================ + +/// Plex ping (V2) +#[tauri::command] +pub async fn v2_plex_ping( + baseUrl: String, + token: String, +) -> Result { + log::info!("[V2] plex_ping"); + crate::plex::plex_ping(baseUrl, token).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex get music sections (V2) +#[tauri::command] +pub async fn v2_plex_get_music_sections( + baseUrl: String, + token: String, +) -> Result, RuntimeError> { + log::info!("[V2] plex_get_music_sections"); + crate::plex::plex_get_music_sections(baseUrl, token).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex get section tracks (V2) +#[tauri::command] +pub async fn v2_plex_get_section_tracks( + baseUrl: String, + token: String, + sectionKey: String, + limit: Option, +) -> Result, RuntimeError> { + log::info!("[V2] plex_get_section_tracks section={}", sectionKey); + crate::plex::plex_get_section_tracks(baseUrl, token, sectionKey, limit).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex get track metadata (V2) +#[tauri::command] +pub async fn v2_plex_get_track_metadata( + baseUrl: String, + token: String, + ratingKey: String, +) -> Result { + log::info!("[V2] plex_get_track_metadata rating_key={}", ratingKey); + crate::plex::plex_get_track_metadata(baseUrl, token, ratingKey).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex auth pin start (V2) +#[tauri::command] +pub async fn v2_plex_auth_pin_start( + clientIdentifier: String, +) -> Result { + log::info!("[V2] plex_auth_pin_start"); + crate::plex::plex_auth_pin_start(clientIdentifier).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex auth pin check (V2) +#[tauri::command] +pub async fn v2_plex_auth_pin_check( + clientIdentifier: String, + pinId: u64, + code: Option, +) -> Result { + log::info!("[V2] plex_auth_pin_check pin_id={}", pinId); + crate::plex::plex_auth_pin_check(clientIdentifier, pinId, code).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex open auth URL (V2) +#[tauri::command] +pub async fn v2_plex_open_auth_url( + url: String, +) -> Result<(), RuntimeError> { + log::info!("[V2] plex_open_auth_url"); + crate::plex::plex_open_auth_url(url).await + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache get sections (V2) +#[tauri::command] +pub fn v2_plex_cache_get_sections() -> Result, RuntimeError> { + log::info!("[V2] plex_cache_get_sections"); + crate::plex::plex_cache_get_sections() + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache save sections (V2) +#[tauri::command] +pub fn v2_plex_cache_save_sections( + serverId: Option, + sections: Vec, +) -> Result { + log::info!("[V2] plex_cache_save_sections count={}", sections.len()); + crate::plex::plex_cache_save_sections(serverId, sections) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache get tracks (V2) +#[tauri::command] +pub fn v2_plex_cache_get_tracks( + sectionKey: Option, + limit: Option, +) -> Result, RuntimeError> { + log::info!("[V2] plex_cache_get_tracks section={:?}", sectionKey); + crate::plex::plex_cache_get_tracks(sectionKey, limit) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache get albums (V2) +#[tauri::command] +pub fn v2_plex_cache_get_albums() -> Result, RuntimeError> { + log::info!("[V2] plex_cache_get_albums"); + crate::plex::plex_cache_get_albums() + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache get album tracks (V2) +#[tauri::command] +pub fn v2_plex_cache_get_album_tracks( + albumKey: String, +) -> Result, RuntimeError> { + log::info!("[V2] plex_cache_get_album_tracks album={}", albumKey); + crate::plex::plex_cache_get_album_tracks(albumKey) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache search tracks (V2) +#[tauri::command] +pub fn v2_plex_cache_search_tracks( + query: String, + limit: Option, +) -> Result, RuntimeError> { + log::info!("[V2] plex_cache_search_tracks query={}", query); + crate::plex::plex_cache_search_tracks(query, limit) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache save tracks (V2) +#[tauri::command] +pub fn v2_plex_cache_save_tracks( + serverId: Option, + sectionKey: String, + tracks: Vec, +) -> Result { + log::info!("[V2] plex_cache_save_tracks section={} count={}", sectionKey, tracks.len()); + crate::plex::plex_cache_save_tracks(serverId, sectionKey, tracks) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache update track quality (V2) +#[tauri::command] +pub fn v2_plex_cache_update_track_quality( + updates: Vec, +) -> Result { + log::info!("[V2] plex_cache_update_track_quality count={}", updates.len()); + crate::plex::plex_cache_update_track_quality(updates) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache get tracks needing hydration (V2) +#[tauri::command] +pub fn v2_plex_cache_get_tracks_needing_hydration( + limit: Option, +) -> Result, RuntimeError> { + log::info!("[V2] plex_cache_get_tracks_needing_hydration"); + crate::plex::plex_cache_get_tracks_needing_hydration(limit) + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex cache clear (V2) +#[tauri::command] +pub fn v2_plex_cache_clear() -> Result<(), RuntimeError> { + log::info!("[V2] plex_cache_clear"); + crate::plex::plex_cache_clear() + .map_err(|e| RuntimeError::Internal(e)) +} + +/// Plex play track (V2) +#[tauri::command] +pub async fn v2_plex_play_track( + baseUrl: String, + token: String, + ratingKey: String, + appState: tauri::State<'_, crate::AppState>, +) -> Result { + log::info!("[V2] plex_play_track rating_key={}", ratingKey); + crate::plex::plex_play_track(baseUrl, token, ratingKey, appState).await + .map_err(|e| RuntimeError::Internal(e)) +} + diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 0e814f4a3..8ab16f371 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1374,6 +1374,25 @@ pub fn run() { commands_v2::v2_get_vector_store_stats, commands_v2::v2_clear_offline_cache, commands_v2::v2_clear_saved_credentials, + // Plex V2 + commands_v2::v2_plex_ping, + commands_v2::v2_plex_get_music_sections, + commands_v2::v2_plex_get_section_tracks, + commands_v2::v2_plex_get_track_metadata, + commands_v2::v2_plex_auth_pin_start, + commands_v2::v2_plex_auth_pin_check, + commands_v2::v2_plex_open_auth_url, + commands_v2::v2_plex_cache_get_sections, + commands_v2::v2_plex_cache_save_sections, + commands_v2::v2_plex_cache_get_tracks, + commands_v2::v2_plex_cache_get_albums, + commands_v2::v2_plex_cache_get_album_tracks, + commands_v2::v2_plex_cache_search_tracks, + commands_v2::v2_plex_cache_save_tracks, + commands_v2::v2_plex_cache_update_track_quality, + commands_v2::v2_plex_cache_get_tracks_needing_hydration, + commands_v2::v2_plex_cache_clear, + commands_v2::v2_plex_play_track, ]) .run(tauri::generate_context!()) .expect("error while running tauri application");