From 2989e6b3430c6249289502d52e07aa5f38587125 Mon Sep 17 00:00:00 2001 From: tehkillerbee Date: Wed, 11 Sep 2024 17:23:29 +0200 Subject: [PATCH] Remove deprecated username/pass login method (Fixes #279) Formatting --- tests/test_session.py | 7 ------- tidalapi/session.py | 29 +---------------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/tests/test_session.py b/tests/test_session.py index 990419d..b123af0 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -37,13 +37,6 @@ def test_load_oauth_session(session): assert isinstance(session.user, tidalapi.LoggedInUser) -def test_failed_login(): - session = tidalapi.Session() - with pytest.raises(requests.HTTPError): - session.login("", "") - assert session.check_login() is False - - @pytest.mark.interactive def test_oauth_login(capsys): config = tidalapi.Config(item_limit=20000) diff --git a/tidalapi/session.py b/tidalapi/session.py index 9aa3df1..2f5ce05 100644 --- a/tidalapi/session.py +++ b/tidalapi/session.py @@ -24,7 +24,6 @@ import datetime import hashlib import json -import locale import logging import os import random @@ -46,7 +45,7 @@ cast, no_type_check, ) -from urllib.parse import parse_qs, urlencode, urljoin, urlsplit +from urllib.parse import parse_qs, urlencode, urlsplit import requests from requests.exceptions import HTTPError @@ -416,32 +415,6 @@ def load_oauth_session( return True - def login(self, username: str, password: str) -> bool: - """Logs in to the TIDAL api. - - :param username: The TIDAL username - :param password: The password to your TIDAL account - :return: Returns true if we think the login was successful. - """ - url = urljoin(self.config.api_v1_location, "login/username") - headers: dict[str, str] = {"X-Tidal-Token": self.config.api_token} - payload = { - "username": username, - "password": password, - "clientUniqueKey": format(random.getrandbits(64), "02x"), - } - request = self.request_session.post(url, data=payload, headers=headers) - - if not request.ok: - log.error("Login failed: %s", request.text) - request.raise_for_status() - - body = request.json() - self.session_id = str(body["sessionId"]) - self.country_code = str(body["countryCode"]) - self.user = user.User(self, user_id=body["userId"]).factory() - return True - def login_session_file( self, session_file: Path,