goon/scripts/debug_tpdb_performer.py
goon-foss a4486980a4 style: myslniki em/en z komentarzy i docstringow (calosc repo)
1745 wystapien w 291 plikach (backend, scripts, mobile). Dominowal jeden ksztalt,
' — ' laczace zdania, wiec poszedl przecinek; myslnik otwierajacy mysl zdjety;
zakresy 0–5 i A–Z na dywiz.

Podzial komentarz/kod robil skaner stanow, nie regex, zeby nie ruszyc myslnika
stojacego w stringu albo w wyrazeniu regularnym. Potwierdzone maszynowo: po wycieciu
komentarzy z wersji HEAD i z dysku obie sa identyczne we wszystkich 291 plikach,
czyli poza komentarzami nie zmienilo sie nic. 233 pliki .py parsuja sie bez bledu,
tsc ma te same 11 bledow w tych samych 3 plikach co przed zmiana.

Dwie rzeczy wymagaly poprawki po automacie: wyrownane listy definicji, gdzie myslnik
byl separatorem kolumny (37 miejsc, kolumna przywrocona), i trzy przeniesienia mysli
do nowej linii, gdzie zostawal wiszacy przecinek na poczatku (poprawione recznie).

Bundla nie republikuje: Hermes i tak nie niesie komentarzy, wiec dla uzytkownika
to zero zmiany.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 11:51:57 +02:00

81 lines
3 KiB
Python

"""Diagnostyka: jak filtrować sceny TPDB po performerze.
Próbuje 3 warianty:
A) GET /scenes?performers[]=<uuid> (aktualnie używany)
B) GET /scenes?performer_id=<uuid> (czasem REST tak chce)
C) GET /performers/<slug-or-id>/scenes (osobny endpoint)
Plus: pobiera /performers?q=<name> (top 5), sprawdzić czy nie wybieramy złego performera.
"""
from __future__ import annotations
import sys
import httpx
from app.config import get_settings
def main(name: str) -> None:
settings = get_settings()
token = settings.tpdb_api_token
base = settings.tpdb_base_url.rstrip("/")
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/json",
"User-Agent": "goon/0.1",
}
with httpx.Client(base_url=base, headers=headers, timeout=30.0) as c:
# 1. lookup
r = c.get("/performers", params={"q": name, "per_page": 10})
r.raise_for_status()
data = r.json().get("data") or []
print(f"=== /performers?q={name!r} → {len(data)} matches ===")
for p in data:
print(f" id={p.get('id')} name={p.get('name')!r} slug={p.get('slug')!r} posts={p.get('posts_count')}")
if not data:
return
first = data[0]
pid = first.get("id")
slug = first.get("slug")
# 2. variant A: performers[]
print(f"\n=== A) /scenes?performers[]={pid} ===")
r = c.get("/scenes", params={"performers[]": pid, "per_page": 5})
print(f" status={r.status_code}")
if r.status_code == 200:
j = r.json()
print(f" meta={j.get('meta')} data_len={len(j.get('data') or [])}")
# 3. variant B: performer_id
print(f"\n=== B) /scenes?performer_id={pid} ===")
r = c.get("/scenes", params={"performer_id": pid, "per_page": 5})
print(f" status={r.status_code}")
if r.status_code == 200:
j = r.json()
print(f" meta={j.get('meta')} data_len={len(j.get('data') or [])}")
# 4. variant C: /performers/<slug>/scenes
print(f"\n=== C) /performers/{slug}/scenes ===")
r = c.get(f"/performers/{slug}/scenes", params={"per_page": 5})
print(f" status={r.status_code}")
if r.status_code == 200:
j = r.json()
print(f" meta={j.get('meta')} data_len={len(j.get('data') or [])}")
for s in (j.get("data") or [])[:3]:
print(f" [{s.get('date')}] {s.get('title')!r}")
# 5. variant D: /performers/<id>/scenes
print(f"\n=== D) /performers/{pid}/scenes ===")
r = c.get(f"/performers/{pid}/scenes", params={"per_page": 5})
print(f" status={r.status_code}")
if r.status_code == 200:
j = r.json()
print(f" meta={j.get('meta')} data_len={len(j.get('data') or [])}")
for s in (j.get("data") or [])[:3]:
print(f" [{s.get('date')}] {s.get('title')!r}")
if __name__ == "__main__":
main(sys.argv[1] if len(sys.argv) > 1 else "Kitana Montana")