diff --git a/tidalapi/request.py b/tidalapi/request.py index 90548d1..ff25469 100644 --- a/tidalapi/request.py +++ b/tidalapi/request.py @@ -80,7 +80,7 @@ def basic_request( headers["authorization"] = ( self.session.token_type + " " + self.session.access_token ) - url = urljoin(self.session.config.api_location, path) + url = urljoin(self.session.config.api_v1_location, path) request = self.session.request_session.request( method, url, params=request_params, data=data, headers=headers ) @@ -128,7 +128,12 @@ def request( request = self.basic_request(method, path, params, data, headers) log.debug("request: %s", request.request.url) - request.raise_for_status() + try: + request.raise_for_status() + except Exception as e: + print("Got exception", e) + print("Response was", e.response) + print("Response json was", e.response.json()) if request.content: log.debug("response: %s", json.dumps(request.json(), indent=4)) return request diff --git a/tidalapi/session.py b/tidalapi/session.py index e5ba1ed..c55b590 100644 --- a/tidalapi/session.py +++ b/tidalapi/session.py @@ -22,6 +22,7 @@ import concurrent.futures import datetime import json +import locale import logging import random import time @@ -94,7 +95,8 @@ class Config: Additionally, num_videos will turn into num_tracks in playlists. """ - api_location: str = "https://api.tidal.com/v1/" + api_v1_location: str = "https://api.tidal.com/v1/" + api_v2_location: str = "https://api.tidal.com/v2/" api_token: str client_id: str client_secret: str @@ -382,7 +384,7 @@ def login(self, username: str, password: str) -> bool: :param password: The password to your TIDAL account :return: Returns true if we think the login was successful. """ - url = urljoin(self.config.api_location, "login/username") + url = urljoin(self.config.api_v1_location, "login/username") headers: dict[str, str] = {"X-Tidal-Token": self.config.api_token} payload = { "username": username,