summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/roster.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-node/src/meshbay_node/roster.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-node/src/meshbay_node/roster.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/roster.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/roster.py b/packages/meshbay-node/src/meshbay_node/roster.py
index 6eb7651..701462f 100644
--- a/packages/meshbay-node/src/meshbay_node/roster.py
+++ b/packages/meshbay-node/src/meshbay_node/roster.py
@@ -599,6 +599,52 @@ class Roster:
json.dumps(sorted(apps)), set_by)
return apps
+ # TMDB is one operator's budget and credential, not a per-group concern
+ # (docs/mediacenter.md §5.5) — stored under the group_id="" sentinel,
+ # the same precedent as `roster.get_member("", user_id)` authorizing the
+ # operator node-wide (desktop-client-v1.md §6.3). Unset means "on, using
+ # the shipped default token" — the same "absent means the old behaviour"
+ # discipline member_upload/enabled_apps already follow.
+ SETTING_TMDB_ENABLED = "tmdb_enabled"
+ SETTING_TMDB_TOKEN = "tmdb_api_token"
+ # A TMDB language tag (e.g. "fr-FR") — one for the whole node, same
+ # reasoning as the token: one shared cache, not a per-viewer request.
+ # Unset means TMDB's own default (English) rather than this node
+ # guessing one.
+ SETTING_TMDB_LANGUAGE = "tmdb_language"
+ NODE_WIDE_GROUP_ID = ""
+
+ async def tmdb_config(self) -> tuple[bool, str | None, str | None]:
+ """Returns (enabled, custom_token_or_None, language_or_None)."""
+ enabled = (await self.get_setting(
+ self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_ENABLED, "1")) != "0"
+ token = await self.get_setting(self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_TOKEN)
+ language = await self.get_setting(self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_LANGUAGE)
+ return enabled, (token or None), (language or None)
+
+ async def set_tmdb_config(self, enabled: bool, token: str | None = None,
+ language: str | None = None, set_by: str = "") -> None:
+ await self.set_setting(self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_ENABLED,
+ "1" if enabled else "0", set_by)
+ if token is not None:
+ await self.set_setting(self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_TOKEN,
+ token, set_by)
+ if language is not None:
+ await self.set_setting(self.NODE_WIDE_GROUP_ID, self.SETTING_TMDB_LANGUAGE,
+ language, set_by)
+
+ # Which folder is the Videos app's entry point for this group — per-group
+ # (unlike tmdb_config above), since different groups share different
+ # trees. Empty/unset means the whole group index, exactly as today.
+ SETTING_VIDEO_ROOT = "video_root"
+
+ async def video_root(self, group_id: str) -> str:
+ return await self.get_setting(group_id, self.SETTING_VIDEO_ROOT, "") or ""
+
+ async def set_video_root(self, group_id: str, path: str, set_by: str = "") -> str:
+ await self.set_setting(group_id, self.SETTING_VIDEO_ROOT, path or "", set_by)
+ return path or ""
+
# How often the indexer's reconciliation backstop runs, and how long it
# waits after the last change on a file before hashing it. Unset means
# the indexer's own defaults — an existing group's behaviour must not