mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
use playbackinfopostpaywall
This commit is contained in:
parent
ad5afdc9c6
commit
19e21fd130
@ -1,5 +1,4 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import { DateTime } from "luxon"
|
|
||||||
|
|
||||||
const TIDAL_CLIENT_ID = process.env.TIDAL_CLIENT_ID
|
const TIDAL_CLIENT_ID = process.env.TIDAL_CLIENT_ID
|
||||||
const TIDAL_CLIENT_SECRET = process.env.TIDAL_CLIENT_SECRET
|
const TIDAL_CLIENT_SECRET = process.env.TIDAL_CLIENT_SECRET
|
||||||
@ -74,22 +73,40 @@ export default class TidalAPI {
|
|||||||
track_id,
|
track_id,
|
||||||
quality,
|
quality,
|
||||||
access_token,
|
access_token,
|
||||||
|
country,
|
||||||
}) {
|
}) {
|
||||||
let data = {
|
let params = {
|
||||||
soundQuality: quality ?? "LOSSLESS",
|
countryCode: country ?? "US",
|
||||||
|
audioquality: quality ?? "LOSSLESS",
|
||||||
|
playbackmode: "STREAM",
|
||||||
|
assetpresentation: "FULL",
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios({
|
let response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `https://api.tidal.com/v1/tracks/${track_id}/streamUrl`,
|
url: `https://api.tidal.com/v1/tracks/${track_id}/playbackinfopostpaywall`,
|
||||||
params: data,
|
params: params,
|
||||||
headers: {
|
headers: {
|
||||||
"Origin": "http://listen.tidal.com",
|
Origin: "http://listen.tidal.com",
|
||||||
Authorization: `Bearer ${access_token}`
|
Authorization: `Bearer ${access_token}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return response.data
|
let decodedManifest = JSON.parse(global.b64Decode(response.data.manifest))
|
||||||
|
|
||||||
|
decodedManifest.url = decodedManifest.urls[0]
|
||||||
|
|
||||||
|
return {
|
||||||
|
metadata: {
|
||||||
|
trackId: track_id,
|
||||||
|
audioMode: response.data.audioMode,
|
||||||
|
audioQuality: response.data.audioQuality,
|
||||||
|
bitDepth: response.data.bitDepth,
|
||||||
|
bitRate: response.data.bitRate,
|
||||||
|
mimeType: response.data.manifestMimeType
|
||||||
|
},
|
||||||
|
...decodedManifest
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static async getTrackMetadata({
|
static async getTrackMetadata({
|
||||||
track_id,
|
track_id,
|
||||||
@ -98,7 +115,10 @@ export default class TidalAPI {
|
|||||||
}) {
|
}) {
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `https://api.tidal.com/v1/tracks/${track_id}/?countryCode=${country}`,
|
url: `https://api.tidal.com/v1/tracks/${track_id}`,
|
||||||
|
params: {
|
||||||
|
"countryCode": country
|
||||||
|
},
|
||||||
headers: {
|
headers: {
|
||||||
"Origin": "http://listen.tidal.com",
|
"Origin": "http://listen.tidal.com",
|
||||||
Authorization: `Bearer ${access_token}`
|
Authorization: `Bearer ${access_token}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user