Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion resources/lib/traktapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def __repr__(self) -> str:

class TraktClient:
api_url = "https://api.trakt.tv"
auth_url = "https://auth.trakt.tv"
max_retry_after = 60

def __init__(
Expand All @@ -120,7 +121,7 @@ def request(
include_error_code: bool = False,
base_url: str | None = None,
) -> Any:
url = self.api_url + path
url = (base_url or self.api_url) + path
data = dumps(body).encode("utf-8") if body is not None else None
headers = {
"Content-Type": "application/json",
Expand Down Expand Up @@ -166,6 +167,7 @@ def request(
retry=False,
include_headers=include_headers,
include_error_code=include_error_code,
base_url=base_url,
)
if exc.code == 401 and authorization and authorization.get("refresh_token"):
raise
Expand Down Expand Up @@ -241,6 +243,7 @@ def login(self) -> None:
"/oauth/device/code",
{"client_id": self.client.client_id},
timeout=90,
base_url=self.client.auth_url,
)

if not code:
Expand Down Expand Up @@ -285,6 +288,7 @@ def _poll_device_token(self, code: dict) -> None:
},
timeout=90,
include_error_code=True,
base_url=self.client.auth_url,
)
if token and token.get("access_token"):
self.on_authenticated(token)
Expand Down
Loading