fix(media): TMDb's v3 key travels as a query parameter; Bearer is a JWT only
The first tvdb-grade TV plan built 49,771 moves with not ONE TMDb answer: every search and every external_ids call came back 401. The credential on this box is the v3 key (~/.config/secrets/tmdb, `api_key=`), and TMDb takes a v3 key only as the `api_key` query parameter — a v4 request token is the only thing the Bearer header accepts. Measured on the same credential in one pass: the query form resolves `New Girl (2011)`, the Bearer form raises HTTP 401. tmdb_request() now picks the transport from the shape it was handed (three dot-separated segments = a JWT → Bearer, anything else → query parameter), and the old header comment's reasoning is corrected: a token in argv is world-readable in /proc/<pid>/cmdline, but this URL is built inside the process and never reaches argv, so the query form leaks nothing. The failure mode that let it look like a finished plan is fixed with it. The 401s were stderr-only, so the summary printed a confident move count while every series folder still carried the metadata provider's folder-echo name — the exact junk this contract exists to undo. Provider health is now part of the summary line and of the exceptions file, and a test covers it offline with `env -u TMDB_API_KEY`: a plan that asked and could not ask says NOT provider-complete in both places, and still writes the moves it can justify, because the answers that did arrive are worth their rename.
This commit is contained in:
1 parent
0a365274b6
commit
32b58dd787
3 files changed
+73
-13
No files matched your search
@@ -135,6 +135,22 @@ plan_park() { # the review pile outside the lib
|
||||
--park "$OUTSIDE" --out "$OUT" --exceptions "$EXC"
|
||||
}
|
||||
|
||||
@test "--tmdb with no key is reported as an unfinished plan, not a finished one" {
|
||||
# A dead provider is invisible where it happens: every 401 is one line on
|
||||
# stderr, and a terminal that scrolled past them shows a plan that reads as
|
||||
# complete while every folder still carries the metadata provider's junk. The
|
||||
# plan is still written — the answers that DID arrive are worth their rename —
|
||||
# so the state has to ride in the summary line and in the review file.
|
||||
# env -u keeps this offline no matter what the developer's shell exports.
|
||||
run env -u TMDB_API_KEY python3 "$PLAN" --root "$LIB" --enum "$ENUM" \
|
||||
--titles "$TITLES" --probed "$PROBED" --tmdb-cache "$CACHE" \
|
||||
--movies "$MOVIES" --tmdb --out "$OUT" --exceptions "$EXC"
|
||||
[ "$status" -eq 0 ]
|
||||
grep -q 'tmdb NOT ASKED (TMDB_API_KEY unset): NOT provider-complete' <<<"$output"
|
||||
grep -q 'WARNING: tmdb NOT ASKED (TMDB_API_KEY unset) — NOT provider-complete' "$EXC"
|
||||
grep -qE '^plan: [1-9][0-9]* moves' <<<"$output"
|
||||
}
|
||||
|
||||
@test "the census exports the provider's episode numbering as a TSV" {
|
||||
DB="$BATS_TEST_TMPDIR/jellyfin.db"
|
||||
python3 - "$DB" "$SEASON" <<'PY'
|
||||
|
||||
Reference in new issue
Block a user