feat: overhaul video player controller
This commit is contained in:
+28
-5
@@ -704,7 +704,16 @@ class ControllerStore:
|
||||
title = str(legacy.get("title") or "")
|
||||
count = _coerce_count(legacy.get("item_count", 0), slot, warnings)
|
||||
created_at = _utc_timestamp(legacy.get("created_at"), f"slot {slot} created_at", warnings)
|
||||
expires_at = _utc_timestamp(legacy.get("expires_at"), f"slot {slot} expires_at", warnings)
|
||||
expires_at = _utc_timestamp(
|
||||
legacy.get("expires_at"),
|
||||
f"slot {slot} expires_at",
|
||||
warnings,
|
||||
)
|
||||
if media_state == "error" and expires_at is None:
|
||||
expires_at = now + self.config.retention_seconds
|
||||
warnings.append(
|
||||
f"slot {slot}: missing error expiry defaulted to retention window"
|
||||
)
|
||||
generation = 1
|
||||
connection.execute(
|
||||
"""
|
||||
@@ -816,10 +825,17 @@ class ControllerStore:
|
||||
connection.execute(
|
||||
"""
|
||||
UPDATE slots
|
||||
SET media_state = 'error', last_error = ?, updated_at = ?
|
||||
SET media_state = 'error', last_error = ?,
|
||||
expires_at = COALESCE(expires_at, ?), updated_at = ?
|
||||
WHERE slot_number = ? AND generation = ?
|
||||
""",
|
||||
(message, now, row["slot_number"], row["generation"]),
|
||||
(
|
||||
message,
|
||||
now + self.config.retention_seconds,
|
||||
now,
|
||||
row["slot_number"],
|
||||
row["generation"],
|
||||
),
|
||||
)
|
||||
|
||||
def list_slots(self) -> list[SlotRecord]:
|
||||
@@ -1060,10 +1076,17 @@ class ControllerStore:
|
||||
connection.execute(
|
||||
"""
|
||||
UPDATE slots
|
||||
SET media_state = 'error', last_error = ?, updated_at = ?
|
||||
SET media_state = 'error', last_error = ?,
|
||||
expires_at = COALESCE(expires_at, ?), updated_at = ?
|
||||
WHERE slot_number = ? AND generation = ?
|
||||
""",
|
||||
(error, now, slot, generation),
|
||||
(
|
||||
error,
|
||||
now + self.config.retention_seconds,
|
||||
now,
|
||||
slot,
|
||||
generation,
|
||||
),
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user