From f4fe00d15b7b96fd8b210a9a7ddcb46133da594c Mon Sep 17 00:00:00 2001 From: wralto-user-1 Date: Mon, 2 Nov 2026 22:53:15 +0100 Subject: [PATCH] feat: add cover image display for ABS audiobooks - Add coverUrl to ABS data from coverPath - Update dashboard.html to display cover image with fallback placeholder - Style cover images with rounded corners and shadow - Add error handling for broken image URLs Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- dashboard.html | 87 ++++++++++++++++++++++++++++++++++++++++++------ dashboard_api.py | 10 +++++- 2 files changed, 85 insertions(+), 12 deletions(-) diff --git a/dashboard.html b/dashboard.html index 0ba9002..095d039 100644 --- a/dashboard.html +++ b/dashboard.html @@ -133,6 +133,37 @@ .status-bar .success { color: #44ff44; } + + /* Cover Image Styles */ + .cover-container { + text-align: center; + } + + .cover-image { + max-width: 100%; + max-height: 200px; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); + object-fit: contain; + background: rgba(0, 0, 0, 0.2); + } + + .cover-placeholder { + width: 150px; + height: 150px; + margin: 0 auto; + background: rgba(255, 255, 255, 0.1); + border-radius: 8px; + display: flex; + align-items: center; + justify-content: center; + color: #666; + font-size: 1.5rem; + } + + .audiobook-info { + margin-top: 0.75rem; + } @@ -198,6 +229,13 @@ 99: { icon: 'β›ˆοΈ', text: 'Gewitter mit starkem Hagel' } }; + // Medien-Typ Icons + const mediaTypeIcons = { + 'podcast': 'πŸŽ™οΈ', + 'book': 'πŸ“–', + 'item': 'πŸ“š' + }; + // Uhrzeit und Datum aktualisieren function updateClock() { const now = new Date(); @@ -242,19 +280,46 @@ return; } - let displayText = absData.title; - if (absData.author) displayText = `${absData.title} – ${absData.author}`; + const title = absData.title || 'Unbekannt'; + const author = absData.author || ''; + const coverUrl = absData.coverUrl; + const mediaType = absData.mediaType || 'item'; + const progressPercent = absData.progress || 0; + const currentTime = absData.currentTime || '0:00'; + const duration = absData.duration || '0:00'; + const mediaIcon = mediaTypeIcons[mediaType] || 'πŸ“š'; - const mediaType = absData.mediaType === 'podcast' ? 'πŸŽ™οΈ Podcast' : (absData.mediaType === 'book' ? 'πŸ“– HΓΆrbuch' : 'πŸ“š Medium'); - const progressPercent = absData.progress; - const currentTime = absData.currentTime; - const duration = absData.duration; + let html = ''; - document.getElementById('audiobook').innerHTML = ` -
${displayText}
-
${mediaType}
-
Fortschritt: ${progressPercent}% (${currentTime}/${duration})
- `; + if (coverUrl) { + html = ` +
+ ${title} + +
+
+
${title}
+ ${author ? `
von ${author}
` : ''} +
${progressPercent}% (${currentTime}/${duration})
+
+ `; + } else { + html = ` +
+
${mediaIcon}
+
+
+
${title}
+ ${author ? `
von ${author}
` : ''} +
${progressPercent}% (${currentTime}/${duration})
+
+ `; + } + + document.getElementById('audiobook').innerHTML = html; } // Alle Daten von der API holen diff --git a/dashboard_api.py b/dashboard_api.py index 21cbeef..67fd0ef 100644 --- a/dashboard_api.py +++ b/dashboard_api.py @@ -90,7 +90,7 @@ def fetch_weather(): def fetch_abs_data(): - """Fetch ABS user data and latest audiobook""" + """Fetch ABS user data and latest audiobook with cover""" try: headers = { "Authorization": f"Bearer {ABS_TOKEN}", @@ -125,11 +125,19 @@ def fetch_abs_data(): title = metadata.get("title", "Unbekannt") author = metadata.get("author", "") media_type = item_data.get("mediaType", "item") + + # Get cover URL - construct full URL from coverPath + cover_path = item_data.get("coverPath", "") + cover_url = None + if cover_path: + # Remove leading slash if present and construct full URL + cover_url = f"{ABS_BASE_URL}{cover_path}" if cover_path.startswith("/") else f"{ABS_BASE_URL}/{cover_path}" return { "title": title, "author": author, "mediaType": media_type, + "coverUrl": cover_url, "progress": round(latest.get("progress", 0) * 100), "currentTime": format_duration(latest.get("currentTime", 0)), "duration": format_duration(latest.get("duration", 0)),