Compare commits
6 Commits
61ee174cff
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4733c11832 | ||
|
|
d131948c13 | ||
|
|
31ea3107e6 | ||
|
|
a1b48e35d6 | ||
|
|
296e59e709 | ||
|
|
0a39ac69de |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ test*
|
|||||||
*.old
|
*.old
|
||||||
.venv/
|
.venv/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
media/
|
media/
|
||||||
*.mp4
|
*.mp4
|
||||||
*.mov
|
*.mov
|
||||||
|
|||||||
33
AGENTS.md
Normal file
33
AGENTS.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# CANCOM Simple Signage — Agent Guide
|
||||||
|
|
||||||
|
## Start
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python app.py
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
`python app.py` serves on `http://localhost:5005`. `app.py` runs Flask with `debug=True`, `host="0.0.0.0"`, and `port=5005`.
|
||||||
|
|
||||||
|
## Source Of Truth
|
||||||
|
|
||||||
|
- Single Flask app in `app.py`; there is no database.
|
||||||
|
- Persistent state is `config.json` plus files under `media/<screen>/`.
|
||||||
|
- `README.md` is stale on the port number; trust `app.py`.
|
||||||
|
- Existing repo instructions in this file are the main local guidance; there is no `opencode.json` or workflow config in this repo.
|
||||||
|
|
||||||
|
## Behavior To Preserve
|
||||||
|
|
||||||
|
- `GET /player/<screen>` renders the playlist and auto-reloads from `/playlist/<screen>/hash`.
|
||||||
|
- `GET /admin` requires login; `config.json.admin` holds the credentials.
|
||||||
|
- URL playlist items are stored as dicts like `{"url": "https://...", "zoom": 0.8}` and the zoom value must survive save/reorder flows.
|
||||||
|
- `.html` items in `media/` are rendered inline as content, not in an iframe.
|
||||||
|
- `config.priority.enabled` makes the priority playlist show on every screen.
|
||||||
|
- `POST /api/customer` generates `welcome.html` and inserts it at the front of the lobby playlist.
|
||||||
|
|
||||||
|
## Repo Quirks
|
||||||
|
|
||||||
|
- `media/` and media file extensions are gitignored.
|
||||||
|
- The app has no configured tests, lint, typecheck, formatter, or CI.
|
||||||
|
- Hardcoded secrets exist in tracked files; do not commit new secrets or reshuffle them casually.
|
||||||
@@ -91,7 +91,7 @@ python app.py
|
|||||||
Server läuft auf:
|
Server läuft auf:
|
||||||
|
|
||||||
```
|
```
|
||||||
http://localhost:5000
|
http://localhost:5005
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
101
app.py
101
app.py
@@ -7,7 +7,7 @@ import generate_welcome_page
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
Flask, render_template,
|
Flask, jsonify, render_template,
|
||||||
send_from_directory, redirect,
|
send_from_directory, redirect,
|
||||||
request, abort
|
request, abort
|
||||||
)
|
)
|
||||||
@@ -26,7 +26,7 @@ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||||||
MEDIA_DIR = os.path.join(BASE_DIR, "media")
|
MEDIA_DIR = os.path.join(BASE_DIR, "media")
|
||||||
CONFIG_FILE = os.path.join(BASE_DIR, "config.json")
|
CONFIG_FILE = os.path.join(BASE_DIR, "config.json")
|
||||||
|
|
||||||
APP_VERSION = "4.0.1"
|
APP_VERSION = "4.1.1"
|
||||||
UPLOAD_EXTENSIONS = {".jpg", ".jpeg", ".png", ".mp4"}
|
UPLOAD_EXTENSIONS = {".jpg", ".jpeg", ".png", ".mp4"}
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -70,6 +70,16 @@ def normalize_url(value):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def playlist_item_enabled(item):
|
||||||
|
return not (isinstance(item, dict) and item.get("enabled") is False)
|
||||||
|
|
||||||
|
|
||||||
|
def playlist_item_name(item):
|
||||||
|
if isinstance(item, dict):
|
||||||
|
return item.get("url") or item.get("name")
|
||||||
|
return item
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Auth / Benutzer
|
# Auth / Benutzer
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
@@ -108,7 +118,7 @@ def logout():
|
|||||||
# Customer / Willkommensseite
|
# Customer / Willkommensseite
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
@app.route("/customer", methods=["GET", "POST"])
|
@app.route("/customer", methods=["GET", "POST"])
|
||||||
@login_required
|
# @login_required
|
||||||
def add_customer():
|
def add_customer():
|
||||||
"""Add new customer with logo search and welcome page"""
|
"""Add new customer with logo search and welcome page"""
|
||||||
error = None
|
error = None
|
||||||
@@ -117,7 +127,7 @@ def add_customer():
|
|||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
customer_name = request.form.get("customer_name", "").strip()
|
customer_name = request.form.get("customer_name", "").strip()
|
||||||
|
print(f"🔍 APP.PY - Suche nach Kunde: '{customer_name}'")
|
||||||
if not customer_name:
|
if not customer_name:
|
||||||
error = "Kundenname erforderlich"
|
error = "Kundenname erforderlich"
|
||||||
else:
|
else:
|
||||||
@@ -147,7 +157,7 @@ def add_customer():
|
|||||||
return render_template("customer.html", error=error, success=success, logo_url=logo_url)
|
return render_template("customer.html", error=error, success=success, logo_url=logo_url)
|
||||||
|
|
||||||
@app.route("/api/customer", methods=["POST"])
|
@app.route("/api/customer", methods=["POST"])
|
||||||
@login_required
|
# @login_required
|
||||||
def api_add_customer():
|
def api_add_customer():
|
||||||
"""API endpoint for customer creation"""
|
"""API endpoint for customer creation"""
|
||||||
try:
|
try:
|
||||||
@@ -231,25 +241,29 @@ def player(screen):
|
|||||||
|
|
||||||
# 1. Playlist-Reihenfolge
|
# 1. Playlist-Reihenfolge
|
||||||
for item in playlist:
|
for item in playlist:
|
||||||
|
if not playlist_item_enabled(item):
|
||||||
|
continue
|
||||||
|
item_name = playlist_item_name(item)
|
||||||
if is_url(item):
|
if is_url(item):
|
||||||
url_data = normalize_url(item)
|
url_data = normalize_url(item)
|
||||||
if url_data:
|
if url_data:
|
||||||
normal_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0)})
|
normal_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0), "enabled": True})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if os.path.exists(os.path.join(folder, item)) and allowed_file(item):
|
if item_name and os.path.exists(os.path.join(folder, item_name)) and allowed_file(item_name):
|
||||||
normal_files.append({"kind": "file", "name": item})
|
normal_files.append({"kind": "file", "name": item_name, "enabled": True})
|
||||||
|
|
||||||
existing_file_names = {
|
existing_file_names = {
|
||||||
item["name"] for item in normal_files if item["kind"] == "file"
|
item["name"] for item in normal_files if item["kind"] == "file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2. Neue Dateien hintendran
|
# 2. Neue Dateien hintendran
|
||||||
for f in sorted(os.listdir(folder)):
|
if not playlist:
|
||||||
if f in existing_file_names or f.startswith("._"):
|
for f in sorted(os.listdir(folder)):
|
||||||
continue
|
if f in existing_file_names or f.startswith("._"):
|
||||||
if allowed_file(f):
|
continue
|
||||||
normal_files.append({"kind": "file", "name": f})
|
if allowed_file(f):
|
||||||
|
normal_files.append({"kind": "file", "name": f})
|
||||||
|
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# Priority-Playlist (global)
|
# Priority-Playlist (global)
|
||||||
@@ -260,23 +274,26 @@ def player(screen):
|
|||||||
if priority_cfg.get("enabled", False):
|
if priority_cfg.get("enabled", False):
|
||||||
prio_files = []
|
prio_files = []
|
||||||
for item in priority_cfg.get("playlist", []):
|
for item in priority_cfg.get("playlist", []):
|
||||||
|
if not playlist_item_enabled(item):
|
||||||
|
continue
|
||||||
|
item_name = playlist_item_name(item)
|
||||||
if is_url(item):
|
if is_url(item):
|
||||||
url_data = normalize_url(item)
|
url_data = normalize_url(item)
|
||||||
if url_data:
|
if url_data:
|
||||||
prio_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0)})
|
prio_files.append({"kind": "url", "url": url_data["url"], "zoom": url_data.get("zoom", 1.0), "enabled": True})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = os.path.join(MEDIA_DIR, "priority", item)
|
file_path = os.path.join(MEDIA_DIR, "priority", item_name)
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
prio_files.append({"kind": "file", "name": item})
|
prio_files.append({"kind": "file", "name": item_name, "enabled": True})
|
||||||
else:
|
else:
|
||||||
prio_files = []
|
prio_files = []
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"player.html",
|
"player.html",
|
||||||
screen=screen,
|
screen=screen,
|
||||||
normal_files=normal_files, # ✅ explizit
|
normal_files=[item for item in normal_files if item.get("enabled", True)],
|
||||||
prio_files=prio_files, # ✅ IMMER Liste
|
prio_files=[item for item in prio_files if item.get("enabled", True)],
|
||||||
interval=screen_cfg.get("interval", 10),
|
interval=screen_cfg.get("interval", 10),
|
||||||
newsticker_text=screen_cfg.get("newsticker_text", ""),
|
newsticker_text=screen_cfg.get("newsticker_text", ""),
|
||||||
newsticker_enabled=screen_cfg.get("newsticker_enabled", False)
|
newsticker_enabled=screen_cfg.get("newsticker_enabled", False)
|
||||||
@@ -336,6 +353,8 @@ def admin():
|
|||||||
|
|
||||||
# 1️⃣ Playlist-Reihenfolge
|
# 1️⃣ Playlist-Reihenfolge
|
||||||
for item in playlist:
|
for item in playlist:
|
||||||
|
item_name = playlist_item_name(item)
|
||||||
|
|
||||||
if is_url(item):
|
if is_url(item):
|
||||||
url_data = normalize_url(item)
|
url_data = normalize_url(item)
|
||||||
if url_data:
|
if url_data:
|
||||||
@@ -343,15 +362,16 @@ def admin():
|
|||||||
"name": url_data["url"],
|
"name": url_data["url"],
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"size": "URL",
|
"size": "URL",
|
||||||
"zoom": url_data.get("zoom", 1.0)
|
"zoom": url_data.get("zoom", 1.0),
|
||||||
|
"enabled": playlist_item_enabled(item)
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = os.path.join(path, item)
|
file_path = os.path.join(path, item_name)
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ext = os.path.splitext(item)[1].lower()
|
ext = os.path.splitext(item_name)[1].lower()
|
||||||
if ext == ".mp4":
|
if ext == ".mp4":
|
||||||
ftype = "video"
|
ftype = "video"
|
||||||
if ext in (".jpg", ".jpeg", ".png"):
|
if ext in (".jpg", ".jpeg", ".png"):
|
||||||
@@ -362,14 +382,16 @@ def admin():
|
|||||||
size = os.path.getsize(file_path) // 1024
|
size = os.path.getsize(file_path) // 1024
|
||||||
|
|
||||||
files.append({
|
files.append({
|
||||||
"name": item,
|
"name": item_name,
|
||||||
"type": ftype,
|
"type": ftype,
|
||||||
"size": size
|
"size": size,
|
||||||
|
"enabled": playlist_item_enabled(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
||||||
|
playlist_names = {playlist_item_name(item) for item in playlist}
|
||||||
for f in sorted(os.listdir(path)):
|
for f in sorted(os.listdir(path)):
|
||||||
if f in playlist or f.startswith("._"):
|
if f in playlist_names or f.startswith("._"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = os.path.join(path, f)
|
file_path = os.path.join(path, f)
|
||||||
@@ -397,6 +419,7 @@ def admin():
|
|||||||
|
|
||||||
# 1️⃣ Playlist-Reihenfolge
|
# 1️⃣ Playlist-Reihenfolge
|
||||||
for item in prio_playlist:
|
for item in prio_playlist:
|
||||||
|
item_name = playlist_item_name(item)
|
||||||
if is_url(item):
|
if is_url(item):
|
||||||
url_data = normalize_url(item)
|
url_data = normalize_url(item)
|
||||||
if url_data:
|
if url_data:
|
||||||
@@ -404,22 +427,24 @@ def admin():
|
|||||||
"name": url_data["url"],
|
"name": url_data["url"],
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"size": "URL",
|
"size": "URL",
|
||||||
"zoom": url_data.get("zoom", 1.0)
|
"zoom": url_data.get("zoom", 1.0),
|
||||||
})
|
"enabled": playlist_item_enabled(item)
|
||||||
|
})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = os.path.join(prio_dir, item)
|
file_path = os.path.join(prio_dir, item_name)
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ext = os.path.splitext(item)[1].lower()
|
ext = os.path.splitext(item_name)[1].lower()
|
||||||
ftype = "video" if ext == ".mp4" else "image"
|
ftype = "video" if ext == ".mp4" else "image"
|
||||||
size = os.path.getsize(file_path) // 1024
|
size = os.path.getsize(file_path) // 1024
|
||||||
|
|
||||||
priority_files.append({
|
priority_files.append({
|
||||||
"name": item,
|
"name": item_name,
|
||||||
"type": ftype,
|
"type": ftype,
|
||||||
"size": size
|
"size": size,
|
||||||
|
"enabled": playlist_item_enabled(item)
|
||||||
})
|
})
|
||||||
|
|
||||||
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
# 2️⃣ Neue Dateien anhängen (nicht in Playlist)
|
||||||
@@ -576,6 +601,7 @@ def save_playlist(screen):
|
|||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
new_order = data["playlist"] # List of filenames/URLs as strings
|
new_order = data["playlist"] # List of filenames/URLs as strings
|
||||||
|
enabled_map = data.get("enabled", {})
|
||||||
|
|
||||||
# Get the current playlist with all data (including zoom factors)
|
# Get the current playlist with all data (including zoom factors)
|
||||||
if screen == "priority":
|
if screen == "priority":
|
||||||
@@ -586,20 +612,17 @@ def save_playlist(screen):
|
|||||||
# Create a mapping: filename/url -> full item (preserves zoom factor)
|
# Create a mapping: filename/url -> full item (preserves zoom factor)
|
||||||
item_map = {}
|
item_map = {}
|
||||||
for item in old_playlist:
|
for item in old_playlist:
|
||||||
if isinstance(item, dict) and "url" in item:
|
item_map[playlist_item_name(item)] = item
|
||||||
key = item["url"] # URL as key
|
|
||||||
else:
|
|
||||||
key = item # Filename as key
|
|
||||||
item_map[key] = item
|
|
||||||
|
|
||||||
# Build new playlist: use the mapping to preserve zoom factors
|
# Build new playlist: use the mapping to preserve zoom factors
|
||||||
new_playlist = []
|
new_playlist = []
|
||||||
for key in new_order:
|
for key in new_order:
|
||||||
if key in item_map:
|
if key in item_map:
|
||||||
new_playlist.append(item_map[key])
|
item = dict(item_map[key]) if isinstance(item_map[key], dict) else {"name": item_map[key]}
|
||||||
|
item["enabled"] = enabled_map.get(key, True if not isinstance(item_map[key], dict) else item_map[key].get("enabled", True))
|
||||||
|
new_playlist.append(item)
|
||||||
else:
|
else:
|
||||||
# Item not found in mapping - add as is
|
new_playlist.append({"url": key, "zoom": 1.0, "enabled": enabled_map.get(key, True)} if is_url(key) else {"name": key, "enabled": enabled_map.get(key, True)})
|
||||||
new_playlist.append(key)
|
|
||||||
|
|
||||||
if screen == "priority":
|
if screen == "priority":
|
||||||
cfg.setdefault("priority", {})["playlist"] = new_playlist
|
cfg.setdefault("priority", {})["playlist"] = new_playlist
|
||||||
@@ -614,4 +637,4 @@ def save_playlist(screen):
|
|||||||
# Main
|
# Main
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True, host="0.0.0.0", port=5005)
|
app.run(debug=True, host="0.0.0.0", port=5005)
|
||||||
|
|||||||
36
config.json
36
config.json
@@ -4,7 +4,8 @@
|
|||||||
"playlist": [
|
"playlist": [
|
||||||
{
|
{
|
||||||
"url": "https://wbxroompresence.cancom.io/standort?find=Stuttgart",
|
"url": "https://wbxroompresence.cancom.io/standort?find=Stuttgart",
|
||||||
"zoom": 0.8
|
"zoom": 0.8,
|
||||||
|
"enabled": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -16,10 +17,27 @@
|
|||||||
"playlist": [
|
"playlist": [
|
||||||
"welcome.html",
|
"welcome.html",
|
||||||
{
|
{
|
||||||
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
"name": "welcome.html",
|
||||||
"zoom": 1.0
|
"enabled": true
|
||||||
},
|
},
|
||||||
"Cancom_Leitsatz.JPG"
|
{
|
||||||
|
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
||||||
|
"zoom": 1.0,
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Cancom_Leitsatz.JPG",
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "http://localhost:5005/static/heise.html",
|
||||||
|
"zoom": 0.9,
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "heise.html",
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"newsticker_text": "Herzlich Willkommen bei der CANCOM - wir begr\u00fc\u00dfen unsere G\u00e4ste und w\u00fcnschen Ihnen einen angenehmen Tag! !",
|
"newsticker_text": "Herzlich Willkommen bei der CANCOM - wir begr\u00fc\u00dfen unsere G\u00e4ste und w\u00fcnschen Ihnen einen angenehmen Tag! !",
|
||||||
"newsticker_enabled": true
|
"newsticker_enabled": true
|
||||||
@@ -29,13 +47,15 @@
|
|||||||
"show_images": true,
|
"show_images": true,
|
||||||
"show_videos": true,
|
"show_videos": true,
|
||||||
"playlist": [
|
"playlist": [
|
||||||
"https://wbxroompresence.cancom.io/standort?find=Stuttgart",
|
|
||||||
{
|
{
|
||||||
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
"url": "https://www.meteoblue.com/en/meteotv/d7b0fd",
|
||||||
"zoom": 1.0
|
"zoom": 1.0,
|
||||||
|
"enabled": true
|
||||||
},
|
},
|
||||||
"Video_CANCOM_Jahresruckblick_2025.MP4",
|
{
|
||||||
"Video_CANCOM_LIVE_2025_Stuttgart.MP4"
|
"name": "Video_CANCOM_LIVE_2025_Stuttgart.MP4",
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"newsticker_text": "Herzlich willkommen bei der CANCOM - wir w\u00fcnschen ihnen einen sch\u00f6nen Tag",
|
"newsticker_text": "Herzlich willkommen bei der CANCOM - wir w\u00fcnschen ihnen einen sch\u00f6nen Tag",
|
||||||
"newsticker_enabled": true
|
"newsticker_enabled": true
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
version: "3.9"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
signage:
|
signage:
|
||||||
@@ -13,5 +12,5 @@ services:
|
|||||||
- "5005:5005"
|
- "5005:5005"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- OPENAI_API_KEY= "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"
|
- OPENAI_API_KEY="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"
|
||||||
- BRANDFETCH_API_KEY = "eBwCQW_DcQ_jvdqZRNph0JBtRA36XoMTufaaU4AoirOBnqXX9fMqHDw7uYfiz8kSFYMNKGMZtuHxrmud9hn0WQ"
|
- BRANDFETCH_API_KEY="eBwCQW_DcQ_jvdqZRNph0JBtRA36XoMTufaaU4AoirOBnqXX9fMqHDw7uYfiz8kSFYMNKGMZtuHxrmud9hn0WQ"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from openai import OpenAI
|
|||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
# Customer / Willkommensseite
|
# Customer / Willkommensseite
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
|
|
||||||
WELCOME_DIR = os.path.join(os.path.dirname(__file__), "media", "lobby")
|
WELCOME_DIR = os.path.join(os.path.dirname(__file__), "media", "lobby")
|
||||||
|
|
||||||
os.makedirs(WELCOME_DIR, exist_ok=True)
|
os.makedirs(WELCOME_DIR, exist_ok=True)
|
||||||
@@ -13,25 +14,27 @@ WELCOME_FILENAME = "welcome.html"
|
|||||||
|
|
||||||
def get_openai_client():
|
def get_openai_client():
|
||||||
"""Initialize OpenAI client from environment variable"""
|
"""Initialize OpenAI client from environment variable"""
|
||||||
api_key = os.getenv("OPENAI_API_KEY")
|
# api_key = os.getenv("OPENAI_API_KEY")
|
||||||
|
api_key = "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"
|
||||||
if not api_key:
|
if not api_key:
|
||||||
raise ValueError("OPENAI_API_KEY environment variable not set")
|
raise ValueError("OPENAI_API_KEY environment variable not set")
|
||||||
return OpenAI(api_key=api_key)
|
return OpenAI(api_key=api_key)
|
||||||
|
|
||||||
def get_brandfetch_logo(domain):
|
def get_brandfetch_logo(domain):
|
||||||
"""Try to fetch a logo URL from Brandfetch CDN."""
|
"""Try to fetch a logo URL from Brandfetch CDN."""
|
||||||
print(f"🔍 Versuche Brandfetch für Domain: {domain}")
|
print(f"🔍 Generate - Versuche Brandfetch für Domain: {domain}")
|
||||||
# Direct CDN URL construction - Brandfetch provides logos via cdn.brandfetch.io
|
# Direct CDN URL construction - Brandfetch provides logos via cdn.brandfetch.io
|
||||||
logo_url = f"https://cdn.brandfetch.io/{domain}?c=1idyd4Tpb2nKaXIIc8T"
|
logo_url = f"https://cdn.brandfetch.io/{domain}/logo?c=1idyd4Tpb2nKaXIIc8T"
|
||||||
|
|
||||||
# if validate_logo_url(logo_url):
|
# if validate_logo_url(logo_url):
|
||||||
print(f"✅ Brandfetch Logo gefunden: {logo_url}")
|
print(f"✅ Generate - Brandfetch Logo gefunden: {logo_url}")
|
||||||
return logo_url
|
return logo_url
|
||||||
|
|
||||||
# return None
|
# return None
|
||||||
|
|
||||||
|
|
||||||
def search_customer_logo(customer_name):
|
def search_customer_logo(customer_name):
|
||||||
|
print(f"✅ Generate - Suche nach Kundenlogo für: {customer_name}")
|
||||||
"""Search for customer logo URL using OpenAI and web search"""
|
"""Search for customer logo URL using OpenAI and web search"""
|
||||||
try:
|
try:
|
||||||
client = get_openai_client()
|
client = get_openai_client()
|
||||||
@@ -71,9 +74,10 @@ def search_customer_logo(customer_name):
|
|||||||
|
|
||||||
|
|
||||||
def generate_welcome_html(customer_name, logo_url):
|
def generate_welcome_html(customer_name, logo_url):
|
||||||
|
print(f"✅ Generate - Willkommensseite wird generiert für: {customer_name} mit Logo: {logo_url}")
|
||||||
"""Generate a welcome page HTML with full-screen design"""
|
"""Generate a welcome page HTML with full-screen design"""
|
||||||
# CANCOM SVG logo inline
|
# CANCOM SVG logo inline
|
||||||
cancom_svg = '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xcs="https://www.xtool.com/pages/software" version="1.1" preserveAspectRatio="xMinYMin meet" width="61.682394106284505mm" height="9.909010347638684mm" viewBox="136.55880294685778 209.2954948261807 61.682394106284505 9.909010347638684" xcs:version="2.7.22"><style></style><path transform="matrix(0.158038,0,0,0.158038,133.2558,163.322122)" stroke="none" fill="#ffffff" data-view-type="laser" d="M125.9,352.1h18.9L119,291.7h-16.2l-25,60.4h18.2l14.6-38.9L125.9,352.1z M323.6,322 c0,8.8-6.1,16.4-15.4,16.4c-9.1,0-15.4-7.6-15.4-16.4s6.1-16.4,15.2-16.4C317,305.6,323.6,313.4,323.6,322 M340.5,322.3 c0-17.4-13.4-31.3-32.3-31.3c-18.7,0-32.3,14.1-32.3,31.3c0,17.4,13.4,31.3,32.3,31.3C326.9,353.6,340.5,339.4,340.5,322.3 M230.4,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.2,0-31.6,14.1-31.6,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C236.5,338.4,230.4,331.4,230.4,322.5 M38,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.4,0-31.8,14.1-31.8,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C44,338.4,38,331.4,38,322.5 M191.8,352.1h14.4v-59.8H190v33.1l-25-33.1h-15.4v60.1h16.2v-34.1L191.8,352.1z M411.2,352.1v-59.8h-17.7l-14.4,23.2l-14.4-23.2 h-17.7v60.1h16.4V318l15.4,23.2h0.3l15.4-23.5v34.6L411.2,352.1L411.2,352.1z" fill-rule="nonzero"></path></svg>'''
|
cancom_svg = '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xcs="https://www.xtool.com/pages/software" version="1.1" preserveAspectRatio="xMinYMin meet" width="61.682394106284505mm" height="9.909010347638684mm" viewBox="136.55880294685778 209.2954948261807 61.682394106284505 9.909010347638684" xcs:version="2.7.22"><style></style><path transform="matrix(0.158038,0,0,0.158038,133.2558,163.322122)" stroke="none" fill="currentColor" data-view-type="laser" d="M125.9,352.1h18.9L119,291.7h-16.2l-25,60.4h18.2l14.6-38.9L125.9,352.1z M323.6,322 c0,8.8-6.1,16.4-15.4,16.4c-9.1,0-15.4-7.6-15.4-16.4s6.1-16.4,15.2-16.4C317,305.6,323.6,313.4,323.6,322 M340.5,322.3 c0-17.4-13.4-31.3-32.3-31.3c-18.7,0-32.3,14.1-32.3,31.3c0,17.4,13.4,31.3,32.3,31.3C326.9,353.6,340.5,339.4,340.5,322.3 M230.4,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.2,0-31.6,14.1-31.6,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C236.5,338.4,230.4,331.4,230.4,322.5 M38,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.4,0-31.8,14.1-31.8,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C44,338.4,38,331.4,38,322.5 M191.8,352.1h14.4v-59.8H190v33.1l-25-33.1h-15.4v60.1h16.2v-34.1L191.8,352.1z M411.2,352.1v-59.8h-17.7l-14.4,23.2l-14.4-23.2 h-17.7v60.1h16.4V318l15.4,23.2h0.3l15.4-23.5v34.6L411.2,352.1L411.2,352.1z" fill-rule="nonzero"></path></svg>'''
|
||||||
|
|
||||||
html_content = f"""<!DOCTYPE html>
|
html_content = f"""<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
@@ -126,7 +130,7 @@ def generate_welcome_html(customer_name, logo_url):
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
gap: 20px;
|
gap: 10px;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}}
|
}}
|
||||||
.cancom-logo {{
|
.cancom-logo {{
|
||||||
@@ -136,6 +140,23 @@ def generate_welcome_html(customer_name, logo_url):
|
|||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
|
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
|
||||||
}}
|
}}
|
||||||
|
.meets {{
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #000;
|
||||||
|
margin-top: -8px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}}
|
||||||
|
.customer-logo {{
|
||||||
|
max-width: 300px;
|
||||||
|
max-height: 180px;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
object-fit: contain;
|
||||||
|
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
||||||
|
margin-top: 18px;
|
||||||
|
}}
|
||||||
.customer-logo {{
|
.customer-logo {{
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
max-height: 180px;
|
max-height: 180px;
|
||||||
@@ -209,9 +230,9 @@ def save_welcome_page(customer_name, logo_url):
|
|||||||
f.write(html_content)
|
f.write(html_content)
|
||||||
if os.path.getsize(filepath) == 0:
|
if os.path.getsize(filepath) == 0:
|
||||||
raise IOError("File not written")
|
raise IOError("File not written")
|
||||||
print(f"✅ Willkommensseite generiert für: {customer_name}")
|
print(f"✅ Generate - Willkommensseite generiert für: {customer_name}")
|
||||||
print(f"✅ Willkommensseite gespeichert in: {filepath}")
|
print(f"✅ Generate - Willkommensseite gespeichert in: {filepath}")
|
||||||
print(f"✅ Willkommensseite gespeichert: {WELCOME_FILENAME}")
|
print(f"✅ Generate - Willkommensseite gespeichert: {WELCOME_FILENAME}")
|
||||||
return WELCOME_FILENAME
|
return WELCOME_FILENAME
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error saving welcome page: {e}")
|
print(f"❌ Error saving welcome page: {e}")
|
||||||
@@ -234,8 +255,8 @@ def add_customer_to_lobby_playlist(html_filename):
|
|||||||
playlist.remove(full_filename)
|
playlist.remove(full_filename)
|
||||||
playlist.insert(0, full_filename)
|
playlist.insert(0, full_filename)
|
||||||
save_config(config)
|
save_config(config)
|
||||||
print(f"✅ Willkommensseite in Lobby-Playliste platziert")
|
print(f"✅ Generate - Willkommensseite in Lobby-Playliste platziert")
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Error adding to playlist: {e}")
|
print(f"❌ Generate - Error adding to playlist: {e}")
|
||||||
return False
|
return False
|
||||||
107
static/heise.html
Normal file
107
static/heise.html
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Heise News Ticker</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #F4F6F8;
|
||||||
|
color: #212121;
|
||||||
|
margin: 0;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 1.2em;
|
||||||
|
margin-bottom: .7em;
|
||||||
|
color: #DA002D;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
background: #fff;
|
||||||
|
border-left: 6px solid #DA002D;
|
||||||
|
padding: 0.8em 0.7em 0.8em 1em;
|
||||||
|
font-size: 1.05em;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: 0 2px 6px rgba(218, 0, 45, 0.03);
|
||||||
|
transition: box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
li:hover {
|
||||||
|
box-shadow: 0 4px 18px rgba(218,0,45,0.08), 0 1.5px 4px #DA002D22;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #DA002D;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
color: #B00024;
|
||||||
|
}
|
||||||
|
.time {
|
||||||
|
display: block;
|
||||||
|
color: #6c757d;
|
||||||
|
font-size: 0.95em;
|
||||||
|
font-weight: 400;
|
||||||
|
margin-top: 0.15em;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Heise TOP IT-News</h1>
|
||||||
|
<ul id="news-list"></ul>
|
||||||
|
<script>
|
||||||
|
const FEED_URL = 'https://www.heise.de/rss/heise-atom.xml';
|
||||||
|
|
||||||
|
async function loadNews() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(FEED_URL);
|
||||||
|
const text = await response.text();
|
||||||
|
const parser = new DOMParser();
|
||||||
|
const xml = parser.parseFromString(text, 'application/xml');
|
||||||
|
|
||||||
|
// Atom Feed uses <entry>, not <item>
|
||||||
|
const items = Array.from(xml.getElementsByTagName('entry')).slice(0, 6);
|
||||||
|
const list = document.getElementById('news-list');
|
||||||
|
if (items.length === 0) {
|
||||||
|
list.innerHTML = '<li>Momentan keine News gefunden.</li>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
items.forEach(item => {
|
||||||
|
const title = item.querySelector('title')?.textContent || 'Unbenannt';
|
||||||
|
const link = item.querySelector('link')?.getAttribute('href') || '#';
|
||||||
|
const pubDateRaw = item.querySelector('updated')?.textContent || '';
|
||||||
|
const summaryRaw = item.querySelector('summary')?.textContent || '';
|
||||||
|
|
||||||
|
let formattedDate = '';
|
||||||
|
if (pubDateRaw) {
|
||||||
|
const d = new Date(pubDateRaw);
|
||||||
|
// Format zu TT-MM-JJJJ hh:mm
|
||||||
|
const pad = n => (n<10 ? '0'+n : n);
|
||||||
|
formattedDate = `${pad(d.getDate())}.${pad(d.getMonth()+1)}.${d.getFullYear()} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const li = document.createElement('li');
|
||||||
|
li.innerHTML = `
|
||||||
|
<span class="time">${formattedDate}</span>
|
||||||
|
<a href="${link}" target="_blank">${title}</a>
|
||||||
|
<div class="summary" style="color:#555;font-size:1em;line-height:1.5;margin-top:0.35em;font-weight:400;">
|
||||||
|
${summaryRaw}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
list.appendChild(li);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
document.getElementById('news-list').innerHTML = '<li>Fehler beim Laden des Feeds!</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadNews();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -64,6 +64,7 @@
|
|||||||
.playlist-row {
|
.playlist-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns:
|
grid-template-columns:
|
||||||
|
28px /* Enabled */
|
||||||
1fr /* Name */
|
1fr /* Name */
|
||||||
90px /* Typ */
|
90px /* Typ */
|
||||||
80px /* Größe */
|
80px /* Größe */
|
||||||
@@ -168,7 +169,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- Upload -->
|
<!-- Upload -->
|
||||||
<h4>Medien hochladen</h4>
|
<h4>Medien hochladen - ⚠ PRIORITY Playlist</h4>
|
||||||
<form action="/admin/upload/priority"
|
<form action="/admin/upload/priority"
|
||||||
method="post" enctype="multipart/form-data">
|
method="post" enctype="multipart/form-data">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
@@ -191,13 +192,18 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Playlist -->
|
<!-- Playlist -->
|
||||||
<h4>Playlist Reihenfolge</h4>
|
<h4>Playlist Reihenfolge - ⚠ PRIORITY Playlist</h4>
|
||||||
|
|
||||||
<ul class="list-group mb-3" id="playlist-priority">
|
<ul class="list-group mb-3" id="playlist-priority">
|
||||||
{% for file in priority_files %}
|
{% for file in priority_files %}
|
||||||
<li class="list-group-item playlist-row"
|
<li class="list-group-item playlist-row"
|
||||||
data-file="{{ file.name }}">
|
data-file="{{ file.name }}">
|
||||||
|
|
||||||
|
<input class="form-check-input playlist-enabled"
|
||||||
|
type="checkbox"
|
||||||
|
{% if file.enabled %}checked{% endif %}
|
||||||
|
title="Element aktivieren">
|
||||||
|
|
||||||
<span class="playlist-name"
|
<span class="playlist-name"
|
||||||
{% if file.type == "image" %}
|
{% if file.type == "image" %}
|
||||||
data-bs-toggle="tooltip"
|
data-bs-toggle="tooltip"
|
||||||
@@ -248,7 +254,7 @@
|
|||||||
|
|
||||||
<button class="btn btn-primary"
|
<button class="btn btn-primary"
|
||||||
onclick="savePlaylist('priority')">
|
onclick="savePlaylist('priority')">
|
||||||
Priority-Reihenfolge speichern
|
Priority-Playlist speichern
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -322,7 +328,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<!-- Upload -->
|
<!-- Upload -->
|
||||||
<h2>Medien hochladen / URL hinzufügen</h2>
|
<h2>Medien hochladen / URL hinzufügen - {{ screen }}</h2>
|
||||||
<form action="/admin/upload/{{ screen }}"
|
<form action="/admin/upload/{{ screen }}"
|
||||||
method="post" enctype="multipart/form-data">
|
method="post" enctype="multipart/form-data">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
@@ -347,13 +353,18 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<!-- Playlist -->
|
<!-- Playlist -->
|
||||||
<h2>Playlist Reihenfolge</h2>
|
<h2>Playlist Reihenfolge - {{ screen }}</h2>
|
||||||
|
|
||||||
<ul class="list-group mb-3" id="playlist-{{ screen }}">
|
<ul class="list-group mb-3" id="playlist-{{ screen }}">
|
||||||
{% for file in media_files[screen] %}
|
{% for file in media_files[screen] %}
|
||||||
<li class="list-group-item playlist-row"
|
<li class="list-group-item playlist-row"
|
||||||
data-file="{{ file.name }}">
|
data-file="{{ file.name }}">
|
||||||
|
|
||||||
|
<input class="form-check-input playlist-enabled"
|
||||||
|
type="checkbox"
|
||||||
|
{% if file.enabled %}checked{% endif %}
|
||||||
|
title="Element aktivieren">
|
||||||
|
|
||||||
<span class="playlist-name"
|
<span class="playlist-name"
|
||||||
{% if file.type == "image" %}
|
{% if file.type == "image" %}
|
||||||
data-bs-toggle="tooltip"
|
data-bs-toggle="tooltip"
|
||||||
@@ -400,7 +411,7 @@
|
|||||||
|
|
||||||
<button class="btn btn-primary"
|
<button class="btn btn-primary"
|
||||||
onclick="savePlaylist('{{ screen }}')">
|
onclick="savePlaylist('{{ screen }}')">
|
||||||
Reihenfolge speichern
|
Playlist speichern
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -448,12 +459,22 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
const items = document.querySelectorAll(
|
const items = document.querySelectorAll(
|
||||||
"#playlist-" + screen + " li"
|
"#playlist-" + screen + " li"
|
||||||
);
|
);
|
||||||
|
const playlist = [];
|
||||||
|
|
||||||
|
const enabled = {};
|
||||||
|
items.forEach((item) => {
|
||||||
|
const checkbox = item.querySelector(".playlist-enabled");
|
||||||
|
const fileName = item.dataset.file;
|
||||||
|
enabled[fileName] = !!(checkbox && checkbox.checked);
|
||||||
|
playlist.push(fileName);
|
||||||
|
});
|
||||||
|
|
||||||
fetch("/admin/playlist/" + screen, {
|
fetch("/admin/playlist/" + screen, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
playlist: Array.from(items).map(i => i.dataset.file)
|
playlist: playlist,
|
||||||
|
enabled: enabled
|
||||||
})
|
})
|
||||||
}).then(() => location.reload());
|
}).then(() => location.reload());
|
||||||
}
|
}
|
||||||
@@ -471,5 +492,3 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ function normalizeItem(item) {
|
|||||||
if (item.kind === "url" && !("zoom" in item)) {
|
if (item.kind === "url" && !("zoom" in item)) {
|
||||||
item.zoom = 1.0;
|
item.zoom = 1.0;
|
||||||
}
|
}
|
||||||
|
if (!("enabled" in item)) {
|
||||||
|
item.enabled = true;
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,29 +152,31 @@ function isHtml(item) {
|
|||||||
function getNextItem() {
|
function getNextItem() {
|
||||||
const normalizedNormal = normalFiles.map(normalizeItem);
|
const normalizedNormal = normalFiles.map(normalizeItem);
|
||||||
const normalizedPrio = prioFiles.map(normalizeItem);
|
const normalizedPrio = prioFiles.map(normalizeItem);
|
||||||
|
const activeNormal = normalizedNormal.filter(item => item.enabled !== false);
|
||||||
|
const activePrio = normalizedPrio.filter(item => item.enabled !== false);
|
||||||
|
|
||||||
// ✅ Sonderfall: nur Priority vorhanden
|
// ✅ Sonderfall: nur Priority vorhanden
|
||||||
if (normalizedNormal.length === 0 && normalizedPrio.length > 0) {
|
if (activeNormal.length === 0 && activePrio.length > 0) {
|
||||||
return {
|
return {
|
||||||
item: normalizedPrio[prioIndex++ % normalizedPrio.length],
|
item: activePrio[prioIndex++ % activePrio.length],
|
||||||
isPrio: true
|
isPrio: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Sonderfall: nur normale Playlist vorhanden
|
// ✅ Sonderfall: nur normale Playlist vorhanden
|
||||||
if (normalizedPrio.length === 0 && normalizedNormal.length > 0) {
|
if (activePrio.length === 0 && activeNormal.length > 0) {
|
||||||
return {
|
return {
|
||||||
item: normalizedNormal[normalIndex++ % normalizedNormal.length],
|
item: activeNormal[normalIndex++ % activeNormal.length],
|
||||||
isPrio: false
|
isPrio: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Normal-Phase
|
// ✅ Normal-Phase
|
||||||
if (mode === "normal") {
|
if (mode === "normal") {
|
||||||
const item = normalizedNormal[normalIndex++];
|
const item = activeNormal[normalIndex++];
|
||||||
if (normalIndex >= normalizedNormal.length) {
|
if (normalIndex >= activeNormal.length) {
|
||||||
normalIndex = 0;
|
normalIndex = 0;
|
||||||
if (normalizedPrio.length > 0) {
|
if (activePrio.length > 0) {
|
||||||
mode = "prio"; // ➜ nach kompletter Normal-Playlist wechseln
|
mode = "prio"; // ➜ nach kompletter Normal-Playlist wechseln
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,8 +185,8 @@ function getNextItem() {
|
|||||||
|
|
||||||
// ✅ Priority-Phase
|
// ✅ Priority-Phase
|
||||||
if (mode === "prio") {
|
if (mode === "prio") {
|
||||||
const item = normalizedPrio[prioIndex++];
|
const item = activePrio[prioIndex++];
|
||||||
if (prioIndex >= normalizedPrio.length) {
|
if (prioIndex >= activePrio.length) {
|
||||||
prioIndex = 0;
|
prioIndex = 0;
|
||||||
mode = "normal"; // ➜ nach kompletter Priority zurück
|
mode = "normal"; // ➜ nach kompletter Priority zurück
|
||||||
}
|
}
|
||||||
@@ -280,4 +285,3 @@ setInterval(checkForUpdates, 5000);
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user