diff --git a/dashboard.html b/dashboard.html
index 095d039..e2c38e2 100644
--- a/dashboard.html
+++ b/dashboard.html
@@ -137,15 +137,16 @@
/* Cover Image Styles */
.cover-container {
text-align: center;
+ margin-bottom: 0.75rem;
}
.cover-image {
max-width: 100%;
- max-height: 200px;
+ max-height: 180px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
object-fit: contain;
- background: rgba(0, 0, 0, 0.2);
+ background: rgba(0, 0, 0, 0.3);
}
.cover-placeholder {
@@ -158,11 +159,27 @@
align-items: center;
justify-content: center;
color: #666;
- font-size: 1.5rem;
+ font-size: 3rem;
}
.audiobook-info {
+ text-align: center;
+ }
+
+ .progress-bar-container {
+ width: 100%;
+ background: rgba(255, 255, 255, 0.1);
+ border-radius: 4px;
+ height: 6px;
margin-top: 0.75rem;
+ overflow: hidden;
+ }
+
+ .progress-bar {
+ height: 100%;
+ background: linear-gradient(90deg, #4f46e5, #7c3aed);
+ border-radius: 4px;
+ transition: width 0.3s ease;
}
@@ -291,34 +308,40 @@
let html = '';
+ // Always show cover placeholder or image
+ html += '
';
+
if (coverUrl) {
- html = `
-
-

-
- ${mediaIcon}
-
-
-
-
${title}
- ${author ? `
von ${author}
` : ''}
-
${progressPercent}% (${currentTime}/${duration})
-
+ // Add timestamp to prevent caching
+ const coverUrlWithCache = coverUrl.includes('?')
+ ? `${coverUrl}&t=${Date.now()}`
+ : `${coverUrl}?t=${Date.now()}`;
+
+ html += `
+

+
${mediaIcon}
`;
} else {
- html = `
-
-
-
${title}
- ${author ? `
von ${author}
` : ''}
-
${progressPercent}% (${currentTime}/${duration})
-
- `;
+ html += `
${mediaIcon}
`;
}
+ html += '
';
+
+ html += '';
+ html += `
${title}
`;
+ if (author) {
+ html += `
von ${author}
`;
+ }
+ html += `
${currentTime}/${duration}
`;
+
+ // Progress bar
+ html += '
';
+ html += `
`;
+ html += '
';
+
+ html += `
`;
+
document.getElementById('audiobook').innerHTML = html;
}
diff --git a/dashboard_api.py b/dashboard_api.py
index 67fd0ef..4255896 100644
--- a/dashboard_api.py
+++ b/dashboard_api.py
@@ -9,8 +9,9 @@ Access: http://localhost:5000/
"""
import requests
-from flask import Flask, jsonify, Response
+from flask import Flask, jsonify, Response, send_file
import os
+from io import BytesIO
app = Flask(__name__)
@@ -51,6 +52,11 @@ WEATHER_CODES = {
99: {"icon": "⛈️", "text": "Gewitter mit starkem Hagel"},
}
+ABS_HEADERS = {
+ "Authorization": f"Bearer {ABS_TOKEN}",
+ "Content-Type": "application/json",
+}
+
def format_duration(seconds):
"""Format seconds to HH:MM:SS or MM:SS"""
@@ -90,15 +96,10 @@ def fetch_weather():
def fetch_abs_data():
- """Fetch ABS user data and latest audiobook with cover"""
+ """Fetch ABS user data and latest audiobook with cover proxy URL"""
try:
- headers = {
- "Authorization": f"Bearer {ABS_TOKEN}",
- "Content-Type": "application/json",
- }
-
# Get user data with progress
- response = requests.get(f"{ABS_BASE_URL}/api/me", headers=headers, timeout=10)
+ response = requests.get(f"{ABS_BASE_URL}/api/me", headers=ABS_HEADERS, timeout=10)
response.raise_for_status()
user_data = response.json()
@@ -115,7 +116,7 @@ def fetch_abs_data():
# Get item details
item_response = requests.get(
f"{ABS_BASE_URL}/api/items/{library_item_id}",
- headers=headers,
+ headers=ABS_HEADERS,
timeout=10,
)
item_response.raise_for_status()
@@ -126,18 +127,15 @@ def fetch_abs_data():
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}"
+ # Use proxy URL for cover to avoid CORS issues
+ # The proxy endpoint will fetch the actual cover from ABS
+ cover_proxy_url = f"/api/cover/{library_item_id}"
return {
"title": title,
"author": author,
"mediaType": media_type,
- "coverUrl": cover_url,
+ "coverUrl": cover_proxy_url,
"progress": round(latest.get("progress", 0) * 100),
"currentTime": format_duration(latest.get("currentTime", 0)),
"duration": format_duration(latest.get("duration", 0)),
@@ -149,6 +147,52 @@ def fetch_abs_data():
return None
+@app.route("/api/cover/")
+def get_cover(library_item_id):
+ """Proxy endpoint to fetch cover image from ABS and return it"""
+ try:
+ # Try to get cover from ABS API
+ cover_response = requests.get(
+ f"{ABS_BASE_URL}/api/items/{library_item_id}/cover",
+ headers=ABS_HEADERS,
+ timeout=10,
+ )
+
+ if cover_response.ok and cover_response.content:
+ # Return the image directly
+ return Response(
+ cover_response.content,
+ mimetype=cover_response.headers.get('Content-Type', 'image/jpeg')
+ )
+
+ # Fallback: try static path
+ cover_response = requests.get(
+ f"{ABS_BASE_URL}/metadata/items/{library_item_id}/cover.jpg",
+ headers=ABS_HEADERS,
+ timeout=5,
+ )
+
+ if cover_response.ok and cover_response.content:
+ return Response(
+ cover_response.content,
+ mimetype='image/jpeg'
+ )
+
+ # If no cover found, return a transparent pixel
+ return Response(
+ bytes([0x89, 0x50, 0x4E, 0x47]), # Tiny transparent PNG
+ mimetype='image/png'
+ )
+
+ except Exception as e:
+ print(f"Cover fetch error for {library_item_id}: {e}")
+ # Return transparent pixel on error
+ return Response(
+ bytes([0x89, 0x50, 0x4E, 0x47]),
+ mimetype='image/png'
+ )
+
+
@app.route("/api/dashboard")
def get_dashboard_data():
"""Return combined dashboard data"""