This commit is contained in:
team3
2026-10-01 00:09:16 +02:00
parent 8ddd8208f5
commit bd1694528a
3 changed files with 52 additions and 17 deletions

View File

@@ -44,7 +44,9 @@ PLAYER_LATENZ = 4
# Das Fenster um die Marke: Standard und Grenzen
VORHER = 30
DAUER = 35
MAX_VORHER = 600
# Die Marke ist nur ein Anker — das Fenster darf überall auf dem
# Zeitstrahl liegen, auch weit nach der Marke (vorher negativ)
MAX_VORHER = 4 * 3600
MIN_DAUER = 3
MAX_DAUER = 180
MAX_TITEL = 80
@@ -138,7 +140,7 @@ def aendern(clip_id, session_id, host, titel=None, vorher=None, dauer=None):
if titel is not None:
felder["titel"] = titel.strip()[:MAX_TITEL] or None
if vorher is not None:
felder["vorher"] = max(0, min(MAX_VORHER, float(vorher)))
felder["vorher"] = max(-MAX_VORHER, min(MAX_VORHER, float(vorher)))
if dauer is not None:
felder["dauer"] = max(MIN_DAUER, min(MAX_DAUER, float(dauer)))
fenster_neu = any(
@@ -173,7 +175,7 @@ def _datei_weg(name):
def fenster(row, vorher=None, dauer=None):
"""Start (RFC3339) und Dauer des Ausschnitts um die Marke."""
marke = datetime.fromisoformat(row["marke_at"])
v = row["vorher"] if vorher is None else max(0, min(MAX_VORHER, float(vorher)))
v = row["vorher"] if vorher is None else max(-MAX_VORHER, min(MAX_VORHER, float(vorher)))
d = row["dauer"] if dauer is None else max(MIN_DAUER, min(MAX_DAUER, float(dauer)))
return _iso(marke - timedelta(seconds=v)), d

View File

@@ -128,8 +128,12 @@ def test_fremde_sehen_nichts_der_host_alles(client, client2, zuschauer, hostmodu
def test_fenster_wird_begrenzt_und_macht_schnitt_ungueltig(client, monkeypatch):
m = marke(client)
geaendert = client.patch(f"/api/clips/{m['id']}", json={"vorher": 5000, "dauer": 1, "titel": " Hallo "}).json()
geaendert = client.patch(f"/api/clips/{m['id']}", json={"vorher": 99999, "dauer": 1, "titel": " Hallo "}).json()
assert (geaendert["vorher"], geaendert["dauer"], geaendert["titel"]) == (clips.MAX_VORHER, clips.MIN_DAUER, "Hallo")
# Das Fenster darf auch nach der Marke liegen — bis vier Stunden weit
assert client.patch(f"/api/clips/{m['id']}", json={"vorher": -60}).json()["vorher"] == -60
assert client.patch(f"/api/clips/{m['id']}", json={"vorher": -99999}).json()["vorher"] == -clips.MAX_VORHER
client.patch(f"/api/clips/{m['id']}", json={"vorher": clips.MAX_VORHER, "dauer": 1})
# Schneiden: der Playback-Server wird nachgestellt
class Antwort: