video enrichment: log each match/not-found at INFO (visible in app.log)

The worker only logged exceptions, so a normal run looked dead — no parity with
the music workers' 'Matched ... -> ID' lines. Now logs each match (noting
'(by server id)' when it used the server's provider id) and each not-found at
INFO. Logger is soulsync.video_enrichment.worker, so it already propagates to
app.log; it just had nothing to say. caplog seam test pins it.
This commit is contained in:
BoulderBadgeDad 2026-06-14 15:54:53 -07:00
parent 9b607b3d1b
commit 50632f6392
2 changed files with 16 additions and 0 deletions

View file

@ -119,9 +119,14 @@ class VideoEnrichmentWorker:
self.db.enrichment_apply(self.service, item["kind"], item["id"], matched=True,
external_id=result["id"], metadata=result.get("metadata"))
self.stats["matched"] += 1
# Visible progress in app.log, mirroring the music workers' style.
logger.info("Matched %s '%s' -> %s ID: %s%s", item["kind"], item["title"],
self.display_name, result["id"],
" (by server id)" if item.get("known_id") else "")
else:
self.db.enrichment_apply(self.service, item["kind"], item["id"], matched=False)
self.stats["not_found"] += 1
logger.info("No %s match for %s '%s'", self.display_name, item["kind"], item["title"])
return True
# ── status (same shape the music enrichment API returns) ──────────────────

View file

@ -129,6 +129,17 @@ def test_tvdb_client_refreshes_expired_token(monkeypatch):
assert len(logins) == 2 # initial login + one refresh after the 401
def test_worker_logs_match_progress(db, caplog):
# The worker must log each match at INFO (under soulsync.*) so progress is
# visible in app.log like the music workers — otherwise it looks dead.
db.upsert_movie("plex", {"server_id": "m1", "title": "Dune", "year": 2021})
w = VideoEnrichmentWorker(db, "tmdb", FakeClient({"id": 438631, "metadata": {}}))
with caplog.at_level("INFO", logger="soulsync.video_enrichment.worker"):
w.process_one()
assert any("Matched movie 'Dune'" in r.message and "TMDB ID: 438631" in r.message
for r in caplog.records)
def test_worker_process_one_not_found(db):
db.upsert_movie("plex", {"server_id": "m1", "title": "X"})
w = VideoEnrichmentWorker(db, "tmdb", FakeClient(None))