Added get_tracks_urls method

This commit is contained in:
RemixDev 2021-07-25 11:31:41 +02:00
parent 5cfb415148
commit 20ca19516a
2 changed files with 39 additions and 3 deletions

View file

@ -106,14 +106,20 @@ class Deezer{
this.childs.push({ this.childs.push({
'id': child.USER_ID, 'id': child.USER_ID,
'name': child.BLOG_NAME, 'name': child.BLOG_NAME,
'picture': child.USER_PICTURE || "" 'picture': child.USER_PICTURE || "",
'license_token': child.OPTIONS.license_token,
'can_stream_hq': child.OPTIONS.web_hq || child.OPTIONS.mobile_hq,
'can_stream_lossless': child.OPTIONS.web_lossless || child.OPTIONS.mobile_lossless
}) })
}) })
} else { } else {
this.childs.push({ this.childs.push({
'id': user_data.USER.USER_ID, 'id': user_data.USER.USER_ID,
'name': user_data.USER.BLOG_NAME, 'name': user_data.USER.BLOG_NAME,
'picture': user_data.USER.USER_PICTURE || "" 'picture': user_data.USER.USER_PICTURE || "",
'license_token': user_data.USER.OPTIONS.license_token,
'can_stream_hq': user_data.USER.OPTIONS.web_hq || user_data.USER.OPTIONS.mobile_hq,
'can_stream_lossless': user_data.USER.OPTIONS.web_lossless || user_data.USER.OPTIONS.mobile_lossless
}) })
} }
} }
@ -126,6 +132,36 @@ class Deezer{
return [this.current_user, this.selected_account] return [this.current_user, this.selected_account]
} }
async get_tracks_urls(track_tokens){
if (!Array.isArray(track_tokens)) track_tokens = [track_tokens, ]
if (!this.current_user.license_token) return []
let response = await got.post("https://media.deezer.com/v1/get_url", {
headers: this.http_headers,
cookieJar: this.cookie_jar,
json:{
license_token: this.current_user.license_token,
media: [{
type: "FULL",
formats: [
{ cipher: "BF_CBC_STRIPE", format: "FLAC" },
{ cipher: "BF_CBC_STRIPE", format: "MP3_320" },
{ cipher: "BF_CBC_STRIPE", format: "MP3_256" },
{ cipher: "BF_CBC_STRIPE", format: "MP3_128" },
{ cipher: "BF_CBC_STRIPE", format: "MP3_64" },
{ cipher: "BF_CBC_STRIPE", format: "MP3_MISC" },
{ cipher: "BF_CBC_STRIPE", format: "MP4_RA3" },
{ cipher: "BF_CBC_STRIPE", format: "MP4_RA2" },
{ cipher: "BF_CBC_STRIPE", format: "MP4_RA1" }
]
}],
track_tokens
}
}).json()
return response.data
}
} }
module.exports = { module.exports = {

View file

@ -1,6 +1,6 @@
{ {
"name": "deezer-js", "name": "deezer-js",
"version": "1.0.0", "version": "1.0.1",
"description": "A wrapper for all Deezer's APIs", "description": "A wrapper for all Deezer's APIs",
"main": "deezer/index.js", "main": "deezer/index.js",
"scripts": { "scripts": {