Skip to content

Instantly share code, notes, and snippets.

@nsyntych
Created October 21, 2024 22:41
Show Gist options
  • Save nsyntych/eb867b06dd4350e22785223b1af7696c to your computer and use it in GitHub Desktop.
Save nsyntych/eb867b06dd4350e22785223b1af7696c 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
#!/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"]["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))
@nsyntych
Copy link
Author

Obviously you need to get the deps first:
pip install configparser pathlib tidalapi
and then run:
python tidal_login.py

@guprobr
Copy link

guprobr commented Oct 31, 2024

nice!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment