From 235b81cf24fd49ef245a70b76d6e52ac5931c680 Mon Sep 17 00:00:00 2001 From: wlkns-dev Date: Fri, 6 Nov 2026 21:13:44 +0100 Subject: [PATCH] =?UTF-8?q?Detailansicht:=20Klick=20auf=20Cover/Titel=20?= =?UTF-8?q?=E2=86=92=20Modal=20mit=20Cover=20gro=C3=9F,=20Untertitel,=20Ch?= =?UTF-8?q?ips,=20Rating,=20Genres/Daten,=20Klappentext=20(per=20Audible-A?= =?UTF-8?q?PI),=20direkte=20Aktionen=20(Abspielen/Laden/L=C3=B6schen/Alter?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/audible.rs | 51 ++++++++++++++++++++++ src-tauri/src/lib.rs | 9 ++++ src/App.svelte | 84 ++++++++++++++++++++++++++++++++++++- src/app.css | 91 ++++++++++++++++++++++++++++++++++++++++ src/lib/audible.ts | 13 ++++++ 5 files changed, 246 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/audible.rs b/src-tauri/src/audible.rs index 0015104..7fcff90 100644 --- a/src-tauri/src/audible.rs +++ b/src-tauri/src/audible.rs @@ -361,6 +361,57 @@ pub fn set_alter_note(asin: &str, note: Option) -> Result<(), String> { ) } +/// Einzeldetails per Audible-API (Beschreibung u. a.) — on demand. +#[derive(Debug, Clone, Serialize)] +pub struct BookExtra { + pub description: String, + pub language: String, + pub format_type: String, + pub release_date: String, +} + +pub fn fetch_details(asin: &str) -> Result { + let bin = audible_binary().ok_or_else(|| { + "audible-cli nicht gefunden — pipx install audible-cli".to_string() + })?; + let endpoint = format!( + "/1.0/catalog/products/{asin}?response_groups=product_desc,product_attrs" + ); + let out = Command::new(&bin) + .args(["api", &endpoint]) + .stderr(std::process::Stdio::piped()) + .output() + .map_err(|e| format!("audible api: {e}"))?; + let text = String::from_utf8_lossy(&out.stdout); + let v: serde_json::Value = serde_json::from_str(text.trim()) + .map_err(|e| format!("Details-JSON: {e}"))?; + let p = &v["product"]; + let strip_tags = |h: &str| -> String { + let mut out = String::new(); + let mut tags = 0usize; + for ch in h.chars() { + match ch { + '<' => tags += 1, + '>' => tags = tags.saturating_sub(1), + c if tags == 0 => out.push(c), + _ => {} + } + } + out.trim().to_string() + }; + let desc = p["description"] + .as_str() + .or_else(|| p["merchandising_summary"].as_str()) + .map(strip_tags) + .unwrap_or_default(); + Ok(BookExtra { + description: desc, + language: p["language"].as_str().unwrap_or("").to_string(), + format_type: p["format_type"].as_str().unwrap_or("").to_string(), + release_date: p["release_date"].as_str().unwrap_or("").to_string(), + }) +} + // Manuelle Altersnotizen — lokale JSON-Ablage (siehe labels_path) /// Taugt stderr von audible-cli: Warnungen und Passwort-Prompts raus, diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index abffc11..8d8ea0b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -166,6 +166,14 @@ async fn player_stop(pl: tauri::State<'_, SharedPlayer>) -> Result Result { + tauri::async_runtime::spawn_blocking(move || audible::fetch_details(&asin)) + .await + .map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))? +} + #[tauri::command] async fn bookmark_list(asin: String) -> Result, String> { tauri::async_runtime::spawn_blocking(move || bookmarks::list(&asin)) @@ -283,6 +291,7 @@ pub fn run() { start_decrypt, get_library, get_local_books, + book_details, stream_only, get_alter_notes, set_alter_note, diff --git a/src/App.svelte b/src/App.svelte index 928ec70..75405c5 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -31,6 +31,8 @@ bmSetNote, autostartEnabled, autostartSet, + bookDetails, + type BookExtra, type Bm, type Book, type DlItem, @@ -126,6 +128,29 @@ playerSetPosition(bookmarks[idx]?.time ?? 0) } + // Detailansicht (Titel-Details) + let detail = $state(null) + let detailExtra = $state(null) + let detailLoading = $state(false) + + function openDetail(b: Book): void { + detail = b + detailExtra = null + detailLoading = true + bookDetails(b.asin) + .then((x) => { + // Nur anwenden, wenn noch das gleiche Buch offen ist + if (detail?.asin === b.asin) detailExtra = x + }) + .catch(() => detailExtra = null) + .finally(() => (detailLoading = false)) + } + + function closeDetail(): void { + detail = null + detailExtra = null + } + // Einstellungen (T-032) let settingsOpen = $state(false) let autostart = $state(false) @@ -560,7 +585,7 @@ {@const d = downloads[b.asin]} {@const dlg = activeDl(b)}
-
+
openDetail(b)} onkeydown={(e) => e.key === 'Enter' && openDetail(b)} role="button" tabindex="0"> Cover von {b.title}
-
{b.title}
+
openDetail(b)} onkeydown={(e) => e.key === 'Enter' && openDetail(b)}>{b.title}
{b.authors}
{#if isLocal(b)} @@ -761,6 +786,61 @@ {/if} +{#if detail} + + +{/if} +