Add song.link (Odesli) sharing integration

- Create share module with SongLinkClient for Odesli API
- Support for tracks via ISRC and albums via UPC
- In-memory cache with 1-hour TTL
- Commands: share_track_songlink, share_album_songlink
- Qobuz URL generators for tracks, albums, artists
- Proper error handling for missing identifiers
This commit is contained in:
vicrodh committed 2026-01-09 12:07:48 -06:00
1 parent 7e2740d297
commit ff7b598522
7 files changed
+453

No files matched your search

+2
View File
@@ -11,6 +11,7 @@ pub mod playback;
pub mod playlist;
pub mod queue;
pub mod search;
pub mod share;
pub use auth::*;
pub use cache::*;
@@ -21,3 +22,4 @@ pub use playback::*;
pub use playlist::*;
pub use queue::*;
pub use search::*;
pub use share::*;
+72
View File
@@ -0,0 +1,72 @@
//! Share-related Tauri commands
use tauri::State;
use crate::share::{ShareError, SongLinkClient, SongLinkResponse};
use crate::AppState;
/// Get song.link URL for a track
/// Requires ISRC to be present in the track metadata
#[tauri::command]
pub async fn share_track_songlink(
isrc: Option<String>,
state: State<'_, AppState>,
) -> Result<SongLinkResponse, String> {
let isrc = isrc.ok_or_else(|| {
ShareError::MissingIsrc.to_string()
})?;
if isrc.is_empty() {
return Err(ShareError::MissingIsrc.to_string());
}
log::info!("Command: share_track_songlink ISRC={}", isrc);
state
.songlink
.get_by_isrc(&isrc)
.await
.map_err(|e| e.to_string())
}
/// Get song.link URL for an album
/// Requires UPC to be present in the album metadata
#[tauri::command]
pub async fn share_album_songlink(
upc: Option<String>,
state: State<'_, AppState>,
) -> Result<SongLinkResponse, String> {
let upc = upc.ok_or_else(|| {
ShareError::MissingUpc.to_string()
})?;
if upc.is_empty() {
return Err(ShareError::MissingUpc.to_string());
}
log::info!("Command: share_album_songlink UPC={}", upc);
state
.songlink
.get_by_upc(&upc)
.await
.map_err(|e| e.to_string())
}
/// Generate a Qobuz share URL for a track
#[tauri::command]
pub fn get_qobuz_track_url(track_id: u64) -> String {
format!("https://www.qobuz.com/track/{}", track_id)
}
/// Generate a Qobuz share URL for an album
#[tauri::command]
pub fn get_qobuz_album_url(album_id: String) -> String {
format!("https://open.qobuz.com/album/{}", album_id)
}
/// Generate a Qobuz share URL for an artist
#[tauri::command]
pub fn get_qobuz_artist_url(artist_id: u64) -> String {
format!("https://www.qobuz.com/artist/{}", artist_id)
}