summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-common/src/meshbay_common/protocol.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-24 10:04:46 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-24 10:04:46 +0200
commit6af05abf410bbd038ce7fa6915a659defc509071 (patch)
tree09b1c941fa446b077ff51282fa18250998528263 /packages/meshbay-common/src/meshbay_common/protocol.py
parentc4981454078a59f776d484f0f1828f2fc5eaad09 (diff)
downloadmeshbay-6af05abf410bbd038ce7fa6915a659defc509071.tar.gz
feat(node,hub): add Videos group app (poster grid, flat list, TMDB metadata)
Implements docs/mediacenter.md: a "Videos" group application built on the existing files index rather than a separate catalogue. On the node side, new indexer enrichment (technical probe, filename/season parsing, thumbnail generation) runs per-file once an operator has chosen a video_root for the group, plus a TMDB client for on-demand poster/metadata lookups (never client-side, thumbnails delivered over the existing chunk path). On the hub side, a new video-app.js renders a lazily-mounted poster grid or a thumbnail-only flat list, with TMDB entirely optional per group. Along the way: the global apps registry now drives Settings' default-tab picker instead of a hardcoded list, and the video_root is configured from group Settings (like uploads) rather than from Files, with the node refusing to run any TMDB/thumbnail work until one is set. Fixes several bugs found via live testing against a real library, notably a race between two effects writing the same "image ready" state that could leave a poster grid spinning forever on a same-tab revisit — see mediacenter.md §5.4 for the full account of each one.
Diffstat (limited to 'packages/meshbay-common/src/meshbay_common/protocol.py')
-rw-r--r--packages/meshbay-common/src/meshbay_common/protocol.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/meshbay-common/src/meshbay_common/protocol.py b/packages/meshbay-common/src/meshbay_common/protocol.py
index e1bfb8e..246bd00 100644
--- a/packages/meshbay-common/src/meshbay_common/protocol.py
+++ b/packages/meshbay-common/src/meshbay_common/protocol.py
@@ -90,6 +90,12 @@ class MNP:
APPS_ENABLED_ACK = "apps_enabled_ack"
SET_SCAN_SETTINGS = "set_scan_settings" # operator → node: reconcile/debounce timing
SET_SCAN_SETTINGS_ACK = "set_scan_settings_ack"
+ MEDIA_META_REQ = "media_meta_req" # client → node: TMDB metadata for a path
+ MEDIA_META_RESP = "media_meta_resp" # node → client: TMDB metadata (or none)
+ VIDEO_ROOT = "video_root" # operator → node: which folder is the Videos entry point
+ VIDEO_ROOT_ACK = "video_root_ack"
+ TMDB_CONFIG = "tmdb_config" # operator → node: enable/disable TMDB, set token
+ TMDB_CONFIG_ACK = "tmdb_config_ack" # node → everyone: new TMDB config (never the token)
# Device linking. A new device files a request bound to a code it displays;
# an already-pinned device of the same account approves it. Neither the hub
# nor the node can produce the countersignature.
@@ -141,6 +147,30 @@ class IndexEntry:
thumb_hash: str | None = None # blake3 of thumbnail
uploader_id: str | None = None # user_id of who uploaded (None = pre-existing on disk)
uploader_pk: str | None = None # Ed25519 public key of uploader (base64 raw 32 bytes)
+ width: int | None = None # pixels, video only
+ height: int | None = None # pixels, video only
+ display_title: str | None = None # parsed or cleaned-filename title, Videos app
+ season: int | None = None # parsed season number, Videos app
+ episode: int | None = None # parsed episode number, Videos app
+
+
+def index_entry_wire(e: IndexEntry) -> dict:
+ """
+ The wire-dict shape used by INDEX_SYNC/INDEX_DELTA hand-built messages
+ (as opposed to GroupIndex.serialize()'s asdict() encoding of the whole
+ index). Centralized so the three call sites that build these
+ (webrtc_server._do_index_sync, daemon._broadcast_index_change's two
+ branches) can't drift from each other as fields are added.
+ """
+ return {
+ "id": e.id, "name": e.name, "path": e.path,
+ "size": e.size, "type": e.type, "added_at": e.added_at,
+ "uploader_id": e.uploader_id,
+ "duration": e.duration, "thumb_hash": e.thumb_hash,
+ "width": e.width, "height": e.height,
+ "display_title": e.display_title,
+ "season": e.season, "episode": e.episode,
+ }
@dataclass
@@ -149,6 +179,12 @@ class IndexDelta:
version: int
additions: list[IndexEntry] = field(default_factory=list)
deletions: list[str] = field(default_factory=list) # list of ids
+ # Same id as before (same file, same content hash), different field
+ # values — e.g. the Videos app's async enrichment filling in duration/
+ # thumb_hash/etc. after the file was already indexed with hash+size only.
+ # A distinct list from `additions`: `GroupIndex.diff()` only ever adds an
+ # id here once it has already appeared unchanged in a prior snapshot.
+ updates: list[IndexEntry] = field(default_factory=list)
# ── Chunk request/response ────────────────────────────────────────────────────