Detailansicht: Klick auf Cover/Titel → Modal mit Cover groß, Untertitel, Chips, Rating, Genres/Daten, Klappentext (per Audible-API), direkte Aktionen (Abspielen/Laden/Löschen/Alter)
This commit is contained in:
@ -361,6 +361,57 @@ pub fn set_alter_note(asin: &str, note: Option<String>) -> 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<BookExtra, String> {
|
||||
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,
|
||||
|
||||
@ -166,6 +166,14 @@ async fn player_stop(pl: tauri::State<'_, SharedPlayer>) -> Result<PlayerState,
|
||||
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))?
|
||||
}
|
||||
|
||||
/// Einzeldetails (Beschreibung u. a.) per Audible-API, on demand.
|
||||
#[tauri::command]
|
||||
async fn book_details(asin: String) -> Result<audible::BookExtra, String> {
|
||||
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<Vec<bookmarks::Bookmark>, 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,
|
||||
|
||||
@ -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<Book | null>(null)
|
||||
let detailExtra = $state<BookExtra | null>(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)}
|
||||
<article class="card">
|
||||
<div class="cover">
|
||||
<div class="cover clickable" title="Details" onclick={() => openDetail(b)} onkeydown={(e) => e.key === 'Enter' && openDetail(b)} role="button" tabindex="0">
|
||||
<img
|
||||
src={coverSrc(b)}
|
||||
alt="Cover von {b.title}"
|
||||
@ -576,7 +601,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="meta">
|
||||
<div class="t">{b.title}</div>
|
||||
<div class="t clickable" role="button" tabindex="0" title="Details" onclick={() => openDetail(b)} onkeydown={(e) => e.key === 'Enter' && openDetail(b)}>{b.title}</div>
|
||||
<div class="muted small">{b.authors}</div>
|
||||
<div class="chips">
|
||||
{#if isLocal(b)}
|
||||
@ -761,6 +786,61 @@
|
||||
</main>
|
||||
{/if}
|
||||
|
||||
{#if detail}
|
||||
<div class="backdrop" onclick={closeDetail} role="presentation"></div>
|
||||
<div class="detailpanel" role="dialog" aria-modal="true">
|
||||
<button class="ghost dclose" title="Schließen" onclick={closeDetail}><Icon name="x" size={14} /></button>
|
||||
<div class="dtop">
|
||||
<img class="dcover" src={coverSrc(detail)} alt={detail.title} />
|
||||
<div class="dmeta">
|
||||
<h2 class="dtitle">{detail.title}</h2>
|
||||
{#if detail.subtitle}<p class="muted small">{detail.subtitle}</p>{/if}
|
||||
<p>{detail.authors}{detail.narrators ? ` · Sprecher: ${detail.narrators}` : ''}</p>
|
||||
<div class="chips" style="margin:0.4rem 0">
|
||||
{#if isLocal(detail)}<span class="chip ok"><Icon name="home" size={12} /> lokal</span>
|
||||
{:else}<span class="chip"><Icon name="cloud" size={12} /> Bibliothek</span>{/if}
|
||||
{#if alterNote(detail)}<span class="chip age">{alterNote(detail)}</span>
|
||||
{:else if ageTag(detail)}<span class="chip">{ageTag(detail)}</span>{/if}
|
||||
{#if detail.runtime_length_min > 0}<span class="chip">{fmtRuntime(detail.runtime_length_min)}</span>{/if}
|
||||
{#if detail.rating > 0}<span class="chip">★ {detail.rating.toFixed(1)}{detail.num_ratings > 0 ? ` (${detail.num_ratings})` : ''}</span>{/if}
|
||||
</div>
|
||||
<p class="muted small">
|
||||
{#if detail.genres}Genres: {detail.genres} · {/if}
|
||||
{#if detail.release_date}erschienen {detail.release_date} · {/if}
|
||||
hinzugefügt {detail.date_added.slice(0, 10) || '—'}{detail.purchase_date ? ` · gekauft ${detail.purchase_date.slice(0, 10)}` : ''}
|
||||
</p>
|
||||
<div class="dactions">
|
||||
{#if isLocal(detail)}
|
||||
<button class="primary" title="Abspielen" onclick={() => { abspielen(detail!); closeDetail() }}><Icon name="play" size={14} /> Abspielen</button>
|
||||
{:else if streamOnly[detail.asin]}
|
||||
<button class="ghost" title="Nur Streaming" onclick={() => (info = 'Wiedergabe folgt mit M2 — nur Streaming.')}><Icon name="play" size={14} /> Abspielen</button>
|
||||
{:else}
|
||||
<button class="primary" title="Laden" onclick={() => laden(detail!)}><Icon name="download" size={14} /> Laden</button>
|
||||
{/if}
|
||||
<button class="ghost" title="Altersnote setzen" onclick={() => startEditAlter(detail!)}><Icon name="pencil" size={13} /> Alter</button>
|
||||
{#if isLocal(detail)}
|
||||
<button class="ghost" title="Löschen" onclick={() => { loeschen(detail!); closeDetail() }}><Icon name="trash" size={14} /> Löschen</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dbody">
|
||||
<h3>Klappentext</h3>
|
||||
{#if detailLoading}
|
||||
<p class="muted small">Lade Beschreibung…</p>
|
||||
{:else if detailExtra?.description}
|
||||
<p class="ddesc">{detailExtra.description}</p>
|
||||
<p class="muted small">
|
||||
{detailExtra.format_type === 'unabridged' ? 'Ungekürzt' : detailExtra.format_type || 'Format: unbekannt'}
|
||||
{detailExtra.language ? ` · Sprache: ${detailExtra.language}` : ''}
|
||||
</p>
|
||||
{:else}
|
||||
<p class="muted small">Keine Beschreibung verfügbar (offline?).</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<footer class="statusbar">
|
||||
<span class="statcell">
|
||||
{#if profile}
|
||||
|
||||
91
src/app.css
91
src/app.css
@ -490,3 +490,94 @@ code {
|
||||
.bmpanel {
|
||||
bottom: 5.9rem;
|
||||
}
|
||||
|
||||
/* Detailansicht (Titel-Details) */
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cover.clickable:hover {
|
||||
filter: brightness(1.12);
|
||||
}
|
||||
|
||||
.meta .t.clickable:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(8, 10, 13, 0.65);
|
||||
z-index: 8;
|
||||
}
|
||||
|
||||
.detailpanel {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: min(44rem, calc(100vw - 2rem));
|
||||
max-height: calc(100vh - 8rem);
|
||||
overflow: auto;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 1.2rem 1.4rem;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.dclose {
|
||||
position: absolute;
|
||||
top: 0.6rem;
|
||||
right: 0.6rem;
|
||||
}
|
||||
|
||||
.dtop {
|
||||
display: flex;
|
||||
gap: 1.1rem;
|
||||
}
|
||||
|
||||
.dcover {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
border-radius: 8px;
|
||||
object-fit: cover;
|
||||
flex: none;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.dmeta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dtitle {
|
||||
margin: 0 0 0.2rem;
|
||||
font-size: 1.15rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.dactions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.7rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.dactions button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.dbody h3 {
|
||||
font-size: 0.95rem;
|
||||
margin: 1rem 0 0.35rem;
|
||||
}
|
||||
|
||||
.ddesc {
|
||||
line-height: 1.55;
|
||||
color: var(--fg);
|
||||
margin: 0 0 0.4rem;
|
||||
}
|
||||
|
||||
@ -18,6 +18,11 @@ export interface Book {
|
||||
is_finished: boolean
|
||||
date_added: string
|
||||
genres: string
|
||||
subtitle: string
|
||||
release_date: string
|
||||
rating: number
|
||||
num_ratings: number
|
||||
purchase_date: string
|
||||
local: boolean
|
||||
}
|
||||
|
||||
@ -78,6 +83,14 @@ export const bmSetNote = (asin: string, index: number, note: string) =>
|
||||
invoke<Bm[]>('bookmark_set_note', { asin, index, note })
|
||||
export const autostartEnabled = () => invoke<boolean>('autostart_enabled')
|
||||
export const autostartSet = (on: boolean) => invoke<void>('autostart_set', { on })
|
||||
|
||||
export interface BookExtra {
|
||||
description: string
|
||||
language: string
|
||||
format_type: string
|
||||
release_date: string
|
||||
}
|
||||
export const bookDetails = (asin: string) => invoke<BookExtra>('book_details', { asin })
|
||||
export function fmtClock(sec: number): string {
|
||||
const t = Math.max(0, Math.floor(sec))
|
||||
const h = Math.floor(t / 3600)
|
||||
|
||||
Reference in New Issue
Block a user