Skip to content

Commit

Permalink
Remove all the nonsense and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Kruszynski committed Nov 27, 2023
1 parent f9214bc commit 8caa90b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
11 changes: 3 additions & 8 deletions tidalapi/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ def __init__(self, session: "Session"):
self.config = session.config

def basic_request(

self,
method: Methods,
path: str,
api_version: str = "v1/",
params: Optional[Params] = None,
data: Optional[JsonObj] = None,
headers: Optional[MutableMapping[str, str]] = None
Expand All @@ -83,8 +81,7 @@ def basic_request(
headers["authorization"] = (
self.session.token_type + " " + self.session.access_token
)

url = urljoin(f"{self.session.config.api_location}{api_version}", path)
url = urljoin(self.session.config.api_location, path)
request = self.session.request_session.request(
method, url, params=request_params, data=data, headers=headers
)
Expand Down Expand Up @@ -114,7 +111,6 @@ def request(
self,
method: Methods,
path: str,
api_version: str = "v1/",
params: Optional[Params] = None,
data: Optional[JsonObj] = None,
headers: Optional[MutableMapping[str, str]] = None,
Expand All @@ -131,7 +127,7 @@ def request(
:return: The json data at specified api endpoint.
"""

request = self.basic_request(method, path, api_version, params, data, headers)
request = self.basic_request(method, path, params, data, headers)
log.debug("request: %s", request.request.url)
request.raise_for_status()
if request.content:
Expand All @@ -141,7 +137,6 @@ def request(
def map_request(
self,
url: str,
api_version: str = "v1/",
params: Optional[Params] = None,
parse: Optional[Callable[..., Any]] = None,
) -> Any:
Expand All @@ -156,7 +151,7 @@ def map_request(
:return: The object(s) at the url, with the same type as the class of the parse
method.
"""
json_obj = self.request("GET", url, api_version, params).json()
json_obj = self.request("GET", url, params).json()

return self.map_json(json_obj, parse=parse)

Expand Down
4 changes: 0 additions & 4 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ def __init__(
):
self.quality = quality.value
self.video_quality = video_quality.value
self.api_location = "https://api.tidal.com/"
self.image_url = "https://resources.tidal.com/images/%s/%ix%i.jpg"
self.video_url = "https://resources.tidal.com/videos/%s/%ix%i.mp4"

self.alac = alac

if item_limit > 10000:
Expand Down
4 changes: 2 additions & 2 deletions tidalapi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from copy import copy
from typing import TYPE_CHECKING, Dict, List, Optional, Union, cast
from urllib.parse import urljoin

from tidalapi.types import JsonObj

Expand Down Expand Up @@ -392,8 +393,7 @@ def mixes(self, limit: Optional[int] = 50, offset: int = 0) -> List["MixV2"]:
return cast(
List["MixV2"],
self.requests.map_request(
f"{self.v2_base_url}/mixes",
api_version="v2/",
url=urljoin("https://api.tidal.com/v2", f"{self.v2_base_url}/mixes"),
params=params,
parse=self.session.parse_v2_mix,
),
Expand Down

0 comments on commit 8caa90b

Please sign in to comment.