Skip to content

Commit 74023f5

Browse files
committed
Add legacy home endpoint for backwards compatibility
1 parent cea6bab commit 74023f5

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

tidalapi/session.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,21 +1082,25 @@ def get_user(
10821082

10831083
return user.User(session=self, user_id=user_id).factory()
10841084

1085-
def home(self) -> page.Page:
1085+
def home(self, use_legacy_endpoint: bool = False) -> page.Page:
10861086
"""
1087-
Retrieves the Home page, as seen on https://listen.tidal.com
1087+
Retrieves the Home page, as seen on https://listen.tidal.com, using either the V2 or V1 (legacy) endpoint
10881088
1089+
:param use_legacy_endpoint: (Optional) Request Page from legacy endpoint.
10891090
:return: A :class:`.Page` object with the :class:`.PageCategory` list from the home page
10901091
"""
1091-
params = {"deviceType": "BROWSER", "locale": self.locale, "platform": "WEB"}
1092-
1093-
json_obj = self.request.request(
1094-
"GET",
1095-
"home/feed/static",
1096-
base_url=self.config.api_v2_location,
1097-
params=params,
1098-
).json()
1099-
return self.page.parse(json_obj)
1092+
if not use_legacy_endpoint:
1093+
params = {"deviceType": "BROWSER", "locale": self.locale, "platform": "WEB"}
1094+
1095+
json_obj = self.request.request(
1096+
"GET",
1097+
"home/feed/static",
1098+
base_url=self.config.api_v2_location,
1099+
params=params,
1100+
).json()
1101+
return self.page.parse(json_obj)
1102+
else:
1103+
return self.page.get("pages/home")
11001104

11011105
def explore(self) -> page.Page:
11021106
"""

0 commit comments

Comments
 (0)