aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/transport
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/quic_server.py1
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc/apps/video_meta.py31
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py1
3 files changed, 33 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/quic_server.py b/packages/meshbay-node/src/meshbay_node/transport/quic_server.py
index 96cd752..715448f 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/quic_server.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/quic_server.py
@@ -286,6 +286,7 @@ class _MNPServerProtocol(QuicConnectionProtocol):
group_id=msg.get("group_id", ""),
hosted_groups=self._ctx.get("groups"),
denylist=self._ctx.get("denylist"),
+ node_pk_b64=pk_to_b64(self._ctx["sk_node"].public_key()),
)
except HandshakeError as refusal:
self._send(stream_id, {"type": "error", "detail": str(refusal),
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc/apps/video_meta.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc/apps/video_meta.py
index 9222ad8..834bac4 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc/apps/video_meta.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc/apps/video_meta.py
@@ -169,6 +169,15 @@ class VideoMetaMixin:
await media_cache.put_thumb(thumb_hash, synthetic_id, content)
return thumb_hash
+ def _tmdb_language(self) -> str:
+ """
+ The node-wide TMDB query language, or "" when the operator has not
+ chosen one yet. Read from the live daemon state (kept current by
+ tmdb_config_ack, same source the handshake ack reads), not the DB, so
+ it is a cheap in-memory lookup on the hot metadata path.
+ """
+ return (self._ctx.get("daemon_state") or {}).get("tmdb_language") or ""
+
async def _do_media_meta_request(self, msg: dict) -> None:
"""
docs/MESHBAY_DESIGN.md §9.7: TMDB metadata for one file, resolved from
@@ -250,6 +259,19 @@ class VideoMetaMixin:
self._send({"type": MNP.MEDIA_META_RESP, "v": MNP_VERSION,
"file_id": file_id, "confidence": 0})
return
+ if not self._tmdb_language():
+ # No query language chosen yet: hold off entirely rather than
+ # search now. TMDB would answer in its English default, which
+ # is both the wrong language and a wasted call — the whole
+ # library fetched now would be thrown away and refetched the
+ # moment a language is set, doubling the request count against
+ # TMDB's rate limit. Waiting until the operator has chosen one
+ # is what makes the first (and only) fetch the chosen language
+ # (docs/MESHBAY_DESIGN.md §9.7). The client refetches on the
+ # tmdb_config_ack that carries the new language.
+ self._send({"type": MNP.MEDIA_META_RESP, "v": MNP_VERSION,
+ "file_id": file_id, "confidence": 0})
+ return
result, ratio = await self._tmdb_search(tmdb_client, entry, is_show)
if result is None or ratio < 0.6:
self._send({"type": MNP.MEDIA_META_RESP, "v": MNP_VERSION,
@@ -315,6 +337,15 @@ class VideoMetaMixin:
details = await media_cache.get_season_meta(tmdb_id, season)
if details is None:
+ if not self._tmdb_language():
+ # Same gate as media_meta_req above: no query language yet
+ # means no TMDB call (docs/MESHBAY_DESIGN.md §9.7). A show is
+ # only matched once a language is set, so this is normally
+ # unreachable, but a client holding a tmdb_id from an earlier
+ # session must not reopen an English fetch either.
+ self._send({"type": MNP.SEASON_META_RESP, "v": MNP_VERSION,
+ "tmdb_id": tmdb_id, "season": season, "confidence": 0})
+ return
fetched = await tmdb_client.tv_season(tmdb_id, season)
if fetched is None:
self._send({"type": MNP.SEASON_META_RESP, "v": MNP_VERSION,
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
index 87394d1..eceb2b4 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
@@ -65,6 +65,7 @@ class HandshakeMixin:
group_id=group_id,
hosted_groups=self._ctx.get("groups"),
denylist=self._ctx.get("denylist"),
+ node_pk_b64=self._node_pk_b64(),
)
except HandshakeError as refusal:
# HandshakeError messages are authored to be peer-safe, unlike arbitrary