-
-
Save Cajivah/df5bd06448a2f3bf09534b23d0928043 to your computer and use it in GitHub Desktop.
Login to tidal API using PKCE and update strawberry player settings to support Hi-Res Lossless playback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| import tidalapi | |
| import json | |
| from pathlib import Path | |
| from configparser import ConfigParser | |
| strawberry_conf_file_path = str(Path.home()) + "/.config/strawberry/strawberry.conf" | |
| strawberry_conf_file = ConfigParser() | |
| strawberry_conf_file.read(strawberry_conf_file_path) | |
| session = tidalapi.Session() | |
| session.login_pkce() | |
| creds = { | |
| "token_type": session.token_type, | |
| "session_id": session.session_id, | |
| "access_token": session.access_token, | |
| "refresh_token": session.refresh_token, | |
| } | |
| strawberry_conf_file["Tidal"]["type"] = "2" | |
| strawberry_conf_file["Tidal"]["streamurl"] = "2" | |
| strawberry_conf_file["Tidal"]["oauth"] = "true" | |
| strawberry_conf_file["Tidal"]["enabled"] = "true" | |
| strawberry_conf_file["Tidal"]["client_id"] = session.config.client_id_pkce | |
| strawberry_conf_file["Tidal"]["quality"] = "HI_RES_LOSSLESS" | |
| strawberry_conf_file["Tidal"]["country_code"] = "PL" | |
| strawberry_conf_file["Tidal"]["token_type"] = "Bearer" | |
| strawberry_conf_file["Tidal"]["access_token"] = creds["access_token"] | |
| strawberry_conf_file["Tidal"]["refresh_token"] = creds["refresh_token"] | |
| with open(strawberry_conf_file_path, "w") as configfile: | |
| strawberry_conf_file.write(configfile) | |
| print(json.dumps(creds, indent=4)) |
thanks for this. Had to remove appMode=android from the url tidal login generates in orer for google login option to show up.
I got a few DuplicateOptionErrors, complaining that certain options already exist, e.g. option 'statusdisplaytype' in section 'DiscordRPC' already exists.
The solution: Add a strict=False to the ConfigParser() call. This tells ConfigParser to tolerate duplicate keys in the Strawberry config.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@spirillen Yes that may be the case. We might need to move this there. As for the app secret and ID I believe in the python file I also printed the values so it returns them that is now I got it.
As for the problem you got with tidal, I had the same exact issue. Login and list retrieval successful, but that error popped when I tried to play anything.