Last active
September 12, 2025 11:49
-
-
Save Vocaned/b485b053c99a2081e67f0bd059a08cc4 to your computer and use it in GitHub Desktop.
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
| import requests | |
| import hashlib | |
| from urllib.parse import urlencode | |
| import json | |
| api_key = input('API Key: ') | |
| secret = input('Secret: ') | |
| print(f'Open http://www.last.fm/api/auth/?api_key={api_key}') | |
| token = input('Enter the token: ') | |
| api = 'https://ws.audioscrobbler.com/2.0/' | |
| params = { | |
| 'api_key': api_key, | |
| 'method': 'auth.getSession', | |
| 'token': token | |
| } | |
| sig = hashlib.md5(''.join([f'{k}{v}' for k,v in sorted(params.items())]).encode('utf-8') + secret.encode('utf-8')).hexdigest() | |
| session = requests.get(f'https://ws.audioscrobbler.com/2.0/?{urlencode(params)}&api_sig={sig}&format=json').json() | |
| print(json.dumps({'session': session['session']['key'], 'apikey': api_key, 'apisecret': secret}, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment