aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/media_cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/media_cache.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/media_cache.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/media_cache.py b/packages/meshbay-node/src/meshbay_node/media_cache.py
index 9c692ca..17262bc 100644
--- a/packages/meshbay-node/src/meshbay_node/media_cache.py
+++ b/packages/meshbay-node/src/meshbay_node/media_cache.py
@@ -290,6 +290,33 @@ class MediaCache:
await self._db.commit()
return cur.rowcount
+ async def clear_tmdb_metadata(self) -> int:
+ """
+ Drop every cached TMDB fiche — show/movie details (`tmdb_meta`) and
+ per-season metadata (`season_meta`) — so the next `media_meta_req`
+ refetches each from TMDB. The file->tmdb *matches* (`file_tmdb`) are
+ language-independent and deliberately kept: the match is the same
+ title whatever language its blurb is in.
+
+ Called when the node's TMDB *language* changes (`ops.set_tmdb_config`).
+ A fiche is cached under `tmdb_id` alone, on purpose — there is only
+ ever one node-wide language, so a per-language key would be dead
+ weight — which is exactly why the language it was fetched in is not
+ recorded, and a fiche cached under the old language would otherwise be
+ served unchanged for its whole 30-day TTL after the operator switched.
+ Wiping them on the switch is what makes the new language actually take
+ effect on a library that has already been browsed. Returns the number
+ of rows removed.
+ """
+ if not self._db:
+ return 0
+ cur = await self._db.execute("DELETE FROM tmdb_meta")
+ removed = cur.rowcount
+ cur = await self._db.execute("DELETE FROM season_meta")
+ removed += cur.rowcount
+ await self._db.commit()
+ return removed
+
# ── tmdb id -> metadata json ─────────────────────────────────────────────
async def get_tmdb_meta(self, tmdb_id: str, media_type: str) -> dict | None: