mirror of
https://gitlab.com/RemixDev/deemix-js.git
synced 2024-12-28 18:36:26 +00:00
Fixed possible track_token expiration issues
This commit is contained in:
parent
2d58f931b2
commit
da04a94191
|
@ -155,6 +155,8 @@ async function getPreferredBitrate(dz, track, preferredBitrate, shouldFallback,
|
|||
formats = {...formats_non_360}
|
||||
}
|
||||
|
||||
// Check and renew trackToken before starting the check
|
||||
await track.checkAndRenewTrackToken(dz)
|
||||
for (let i = 0; i < Object.keys(formats).length; i++){
|
||||
// Check bitrates
|
||||
let formatNumber = Object.keys(formats).reverse()[i]
|
||||
|
|
|
@ -4,7 +4,7 @@ const { Album } = require('./Album.js')
|
|||
const { Playlist } = require('./Playlist.js')
|
||||
const { Picture } = require('./Picture.js')
|
||||
const { Lyrics } = require('./Lyrics.js')
|
||||
const { Date } = require('./Date.js')
|
||||
const { Date: dzDate } = require('./Date.js')
|
||||
const { VARIOUS_ARTISTS } = require('./index.js')
|
||||
const { changeCase } = require('../utils/index.js')
|
||||
const { FeaturesOption } = require('../settings.js')
|
||||
|
@ -35,7 +35,7 @@ class Track {
|
|||
this.album = null
|
||||
this.trackNumber = "0"
|
||||
this.discNumber = "0"
|
||||
this.date = new Date()
|
||||
this.date = new dzDate()
|
||||
this.lyrics = null
|
||||
this.bpm = 0
|
||||
this.contributors = {}
|
||||
|
@ -246,6 +246,16 @@ class Track {
|
|||
}
|
||||
}
|
||||
|
||||
async checkAndRenewTrackToken(dz){
|
||||
let now = new Date()
|
||||
let expiration = new Date(this.trackTokenExpiration*1000)
|
||||
if (now > expiration){
|
||||
let newTrack = await dz.gw.get_track_with_fallback(this.id)
|
||||
this.trackToken = newTrack.TRACK_TOKEN
|
||||
this.trackTokenExpiration = newTrack.TRACK_TOKEN_EXPIRE
|
||||
}
|
||||
}
|
||||
|
||||
applySettings(settings){
|
||||
// Check if should save the playlist as a compilation
|
||||
if (settings.tags.savePlaylistAsCompilation && this.playlist){
|
||||
|
|
Loading…
Reference in a new issue