Eerste commit voor rename-mvp

This commit is contained in:
kodi
2026-03-07 09:59:27 +01:00
commit 27cee7395f
12 changed files with 510 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import httpx
from app.config import TVDB_BASE_URL, TVDB_REQUEST_TIMEOUT_SECONDS
from app.services.tvdb_auth_service import TvdbAuthService
class TvdbClient:
def __init__(self):
self.auth = TvdbAuthService()
def get(self, path: str, params: dict | None = None) -> dict:
token = self.auth.get_valid_token()
headers = {"Authorization": f"Bearer {token}"}
with httpx.Client(timeout=TVDB_REQUEST_TIMEOUT_SECONDS) as client:
response = client.get(f"{TVDB_BASE_URL}{path}", params=params, headers=headers)
if response.status_code == 401:
token = self.auth.login_and_store_token()["token"]
headers = {"Authorization": f"Bearer {token}"}
response = client.get(f"{TVDB_BASE_URL}{path}", params=params, headers=headers)
response.raise_for_status()
return response.json()