fixed deezer helper
This commit is contained in:
parent
55383332f8
commit
ef3c9fbf57
|
@ -5,28 +5,40 @@ CLIENT_ID = "172365"
|
||||||
CLIENT_SECRET = "fb0bec7ccc063dab0417eb7b0d847f34"
|
CLIENT_SECRET = "fb0bec7ccc063dab0417eb7b0d847f34"
|
||||||
|
|
||||||
def getAccessToken(email, password):
|
def getAccessToken(email, password):
|
||||||
|
accessToken = None
|
||||||
password = _md5(password)
|
password = _md5(password)
|
||||||
request_hash = _md5(''.join([CLIENT_ID, email, password, CLIENT_SECRET]))
|
request_hash = _md5(''.join([CLIENT_ID, email, password, CLIENT_SECRET]))
|
||||||
response = requests.get(
|
try:
|
||||||
'https://api.deezer.com/auth/token',
|
response = requests.get(
|
||||||
params={
|
'https://api.deezer.com/auth/token',
|
||||||
'app_id': CLIENT_ID,
|
params={
|
||||||
'login': email,
|
'app_id': CLIENT_ID,
|
||||||
'password': password,
|
'login': email,
|
||||||
'hash': request_hash
|
'password': password,
|
||||||
},
|
'hash': request_hash
|
||||||
headers={"User-Agent": USER_AGENT_HEADER}
|
},
|
||||||
).json()
|
headers={"User-Agent": USER_AGENT_HEADER}
|
||||||
return response.get('access_token')
|
).json()
|
||||||
|
accessToken = response.get('access_token')
|
||||||
|
if accessToken == "undefined": accessToken = None
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return accessToken
|
||||||
|
|
||||||
def getArlFromAccessToken(accessToken):
|
def getArlFromAccessToken(accessToken):
|
||||||
|
if not accessToken: return None
|
||||||
|
arl = None
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.get(
|
try:
|
||||||
"https://api.deezer.com/platform/generic/track/3135556",
|
session.get(
|
||||||
headers={"Authorization": f"Bearer {accessToken}", "User-Agent": USER_AGENT_HEADER}
|
"https://api.deezer.com/platform/generic/track/3135556",
|
||||||
)
|
headers={"Authorization": f"Bearer {accessToken}", "User-Agent": USER_AGENT_HEADER}
|
||||||
response = session.get(
|
)
|
||||||
'https://www.deezer.com/ajax/gw-light.php?method=user.getArl&input=3&api_version=1.0&api_token=null',
|
response = session.get(
|
||||||
headers={"User-Agent": USER_AGENT_HEADER}
|
'https://www.deezer.com/ajax/gw-light.php?method=user.getArl&input=3&api_version=1.0&api_token=null',
|
||||||
).json()
|
headers={"User-Agent": USER_AGENT_HEADER}
|
||||||
return response.get('results')
|
).json()
|
||||||
|
arl = response.get('results')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return arl
|
||||||
|
|
Loading…
Reference in New Issue