mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2024-12-28 18:36:26 +00:00
fixed deezer helper
This commit is contained in:
parent
52dcad11a8
commit
c978e9a74c
|
@ -7,34 +7,44 @@ const CLIENT_ID = "172365"
|
|||
const CLIENT_SECRET = "fb0bec7ccc063dab0417eb7b0d847f34"
|
||||
|
||||
async function getAccessToken(email, password){
|
||||
let accessToken = null
|
||||
password = _md5(password, 'utf8')
|
||||
const hash = _md5([CLIENT_ID, email, password, CLIENT_SECRET].join(''), 'utf8')
|
||||
let response = await got.get("https://api.deezer.com/auth/token",{
|
||||
searchParams: {
|
||||
app_id: CLIENT_ID,
|
||||
login: email,
|
||||
password: password,
|
||||
hash
|
||||
},
|
||||
https: {rejectUnauthorized: false},
|
||||
headers: {"User-Agent": USER_AGENT_HEADER}
|
||||
}).json()
|
||||
return response.access_token
|
||||
try {
|
||||
let response = await got.get("https://api.deezer.com/auth/token",{
|
||||
searchParams: {
|
||||
app_id: CLIENT_ID,
|
||||
login: email,
|
||||
password: password,
|
||||
hash
|
||||
},
|
||||
https: {rejectUnauthorized: false},
|
||||
headers: {"User-Agent": USER_AGENT_HEADER}
|
||||
}).json()
|
||||
accessToken = response.access_token
|
||||
if (accessToken == "undefined") accessToken = null
|
||||
} catch { /*empty*/ }
|
||||
return accessToken
|
||||
}
|
||||
|
||||
async function getArlFromAccessToken(accessToken){
|
||||
if (!accessToken) return null
|
||||
let arl = null
|
||||
let cookieJar = new CookieJar()
|
||||
await got.get("https://api.deezer.com/platform/generic/track/3135556", {
|
||||
headers: {"Authorization": `Bearer ${accessToken}`, "User-Agent": USER_AGENT_HEADER},
|
||||
https: {rejectUnauthorized: false},
|
||||
cookieJar
|
||||
})
|
||||
let response = await got.get('https://www.deezer.com/ajax/gw-light.php?method=user.getArl&input=3&api_version=1.0&api_token=null', {
|
||||
headers: {"User-Agent": USER_AGENT_HEADER},
|
||||
https: {rejectUnauthorized: false},
|
||||
cookieJar
|
||||
}).json()
|
||||
return response.results
|
||||
try {
|
||||
await got.get("https://api.deezer.com/platform/generic/track/3135556", {
|
||||
headers: {"Authorization": `Bearer ${accessToken}`, "User-Agent": USER_AGENT_HEADER},
|
||||
https: {rejectUnauthorized: false},
|
||||
cookieJar
|
||||
})
|
||||
let response = await got.get('https://www.deezer.com/ajax/gw-light.php?method=user.getArl&input=3&api_version=1.0&api_token=null', {
|
||||
headers: {"User-Agent": USER_AGENT_HEADER},
|
||||
https: {rejectUnauthorized: false},
|
||||
cookieJar
|
||||
}).json()
|
||||
arl = response.results
|
||||
} catch { /*empty*/ }
|
||||
return arl
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
Loading…
Reference in a new issue