From b21f59f4eb0323ff54cea1dcbcaaed510546eabb Mon Sep 17 00:00:00 2001 From: mrwnslz Date: Fri, 16 Oct 2026 14:42:20 +0200 Subject: [PATCH] =?UTF-8?q?Home:=20H=C3=B6rb=C3=BCcher=20als=20eigener=20B?= =?UTF-8?q?lock,=20ihre=20Kapitel=20nicht=20unter=20Podcasts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ein laufendes Kapitel steht mit „Kapitel i/n · “ unter Hörbücher, sonst das zuletzt gehörte Buch mit ▶ Weiterhören (audiobooks.js __dioraAudiobookGo). Co-Authored-By: Claude Opus 5.5 --- static/js/audiobooks.js | 3 +++ static/js/home.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/static/js/audiobooks.js b/static/js/audiobooks.js index 2fab3fd..29a3fca 100644 --- a/static/js/audiobooks.js +++ b/static/js/audiobooks.js @@ -503,6 +503,9 @@ if (box && fresh) box.innerHTML = fresh.innerHTML; }); + // Home's "Weiterhören" card (home.js) plays the book from where it was left. + window.__dioraAudiobookGo = feedId => goOn(feedId); + // ---- following the player ------------------------------------------------------------ let pollTimer = 0; diff --git a/static/js/home.js b/static/js/home.js index 712ad66..144764a 100644 --- a/static/js/home.js +++ b/static/js/home.js @@ -91,7 +91,7 @@ card = podCard('Läuft auf ' + (r.device || 'einem anderen Gerät'), r.title || '', r.feed || '', r.artwork || '', r.dur ? (r.dur - (r.pos || 0)) / 1000 : 0, r.dur ? (r.pos || 0) / r.dur : 0, ''); - } else if (player.kind === 'podcast') { + } else if (player.kind === 'podcast' && !player.book) { // an audiobook's chapter: under Hörbücher const left = player.dur ? (player.dur - (player.pos || 0)) / 1000 : 0; card = podCard(player.playing ? 'Läuft gerade' : 'Weiterhören', player.title, player.feed, player.artwork, left, player.dur ? (player.pos || 0) / player.dur : 0, @@ -239,6 +239,33 @@ // ---- page --------------------------------------------------------------------- + // ---- Hörbücher (static/js/audiobooks.js) ------------------------------------------- + + function audiobookSection() { + const h = podHost(); + if (!h || !document.getElementById('tab-audiobooks') || !window.__dioraAudiobookGo) return ''; + const player = h.playerState ? parse(h.playerState(), {}) || {} : {}; + let books = []; + try { books = JSON.parse(localStorage.getItem('diora_ab_books') || '[]') || []; } catch (e) {} + let card; + if (player.kind === 'podcast' && player.book) { + const b = player.book; + const left = player.dur ? (player.dur - (player.pos || 0)) / 1000 : 0; + card = podCard((player.playing ? 'Läuft gerade' : 'Weiterhören') + ' · Kapitel ' + (b.index + 1) + '/' + b.chapters, + player.title, b.title || player.feed, player.artwork, left, player.dur ? (player.pos || 0) / player.dur : 0, + ''); + } else { + const b = books.filter(x => x.next && x.last_played_at)[0]; + if (!b) return ''; + card = podCard('Weiterhören · Kapitel ' + (b.next.index + 1) + '/' + b.chapters, b.title, b.author || '', + b.artwork_url, b.total_seconds ? b.total_seconds - b.heard_seconds : 0, + b.total_seconds ? b.heard_seconds / b.total_seconds : 0, + ''); + } + return section('Hörbücher', card, 'audiobooks'); + } + function section(title, body, tabName) { return '

' + esc(title) + '

' + '
' + body + '
'; @@ -256,7 +283,7 @@ } let html = '
diora
'; refreshFeeds(3 * 60000); - for (const part of [booksSection, podcastSection, feedsSection, radioSection, ambientSection]) { + for (const part of [booksSection, audiobookSection, podcastSection, feedsSection, radioSection, ambientSection]) { try { html += part(); } catch (e) { console.warn('home', e); } } if (html !== lastHtml) { @@ -293,6 +320,7 @@ if (q) h.podcastPlayEpisode(JSON.stringify(q), 0); } else if (act === 'pod-resume' && h) h.podcastPlay(Number(el.dataset.id)); else if (act === 'pod-pause' && h) h.podcastToggle(); + else if (act === 'ab-go' && window.__dioraAudiobookGo) window.__dioraAudiobookGo(Number(el.dataset.id)); else if (act === 'pod-here' && h && h.playerTakeOver) h.playerTakeOver(); else if (act === 'pod-open') { if (window.__dioraOpenPlayer && h && parse(h.playerState(), {}).kind) window.__dioraOpenPlayer('podcast');