Files
qbz/crates/qbz-playlist-import/src/http.rs
T
vicrodh 3689a5fda8 feat(slint): add-to-playlist duplicate modal + playlist importer port
Add-to-playlist (Slices 0-3):
- qbz-core: check_playlist_duplicates + pure compute_playlist_duplicates
  (reuses qbz_models::PlaylistDuplicateResult) + unit tests.
- PlaylistDuplicateConfirmModal (Add all / Add new only / Cancel); the
  duplicate check runs on the Qobuz->Qobuz picker branch only (local/Plex
  add directly, mirroring Tauri); the track-id Vec lives Rust-side in a
  stash, never in Slint.
- Inline create-and-add in the picker (online create_playlist, offline ->
  local playlist per D8) + client-side filter (Slint 1.16 has no string
  contains, routed through a Rust callback) + success toasts.

Playlist importer (1:1 Tauri port):
- New headless crate qbz-playlist-import (Spotify/Apple/Tidal/Deezer
  scrapers, Qobuz matcher, importer, progress sink, shared http client;
  copy-not-move from src-tauri, zero tauri deps; 40 unit tests green).
- PlaylistImportModal (two-step fetch-preview -> import with live progress
  bar / log / summary) + controller + sidebar PLAYLISTS menu entry point.

Reco logging staged behind TODO(reco-v1) markers (golden rule: playlist
recommendations ship in Slint v1 once the reco engine is extracted to a
shared crate).

cc
2026-06-11 22:03:46 -06:00

28 lines
1.2 KiB
Rust

//! Shared HTTP client for all providers.
//!
//! The Tauri original built a new connection pool per request (`reqwest::get`
//! in four call sites, `Client::new()` per Tidal fetch, plus a builder client
//! per token fetch) — each one its own fd pool, which exhausted file
//! descriptors (EMFILE) on large imports. One `OnceLock` client fixes that;
//! async flavor of the existing blocking precedent in
//! `qbz-media-controls/src/notify.rs`.
//!
//! UA policy (behavior-faithful): NO default User-Agent on the client —
//! the scrapers go out exactly as before; only the Tidal proxy token request
//! sets [`USER_AGENT`] per-request, as the original did.
/// User-Agent sent to the QBZ credential proxy (Tidal token fetch only).
pub(crate) const USER_AGENT: &str = "QBZ/1.0.0";
const CONNECT_TIMEOUT_SECS: u64 = 10;
pub(crate) fn http() -> &'static reqwest::Client {
static CLIENT: std::sync::OnceLock<reqwest::Client> = std::sync::OnceLock::new();
CLIENT.get_or_init(|| {
reqwest::Client::builder()
.connect_timeout(std::time::Duration::from_secs(CONNECT_TIMEOUT_SECS))
.build()
.expect("static reqwest client")
})
}