mirror of
https://git.gay/lucida/lucida
synced 2025-12-11 20:15:14 +01:00
add deezer session renewal
This commit is contained in:
parent
b842872d0b
commit
847ba0ec30
@ -100,6 +100,10 @@ export default class Deezer implements StreamerWithLogin {
|
||||
method: T,
|
||||
data: { [key: string]: string | number | string[] } = {}
|
||||
): Promise<APIMethod[T]> {
|
||||
// sid + checkForm renewal
|
||||
if (method != 'deezer.getUserData' && method != 'user.getArl' && this.#isSessionExpired())
|
||||
await this.#apiCall('deezer.getUserData')
|
||||
|
||||
let apiToken = this.apiToken
|
||||
if (method == 'deezer.getUserData' || method == 'user.getArl') apiToken = ''
|
||||
|
||||
@ -168,6 +172,10 @@ export default class Deezer implements StreamerWithLogin {
|
||||
return userData
|
||||
}
|
||||
|
||||
#isSessionExpired() {
|
||||
return Date.now() - (this.renewTimestamp ?? 0) >= 3600 * 1000
|
||||
}
|
||||
|
||||
#md5(str: string) {
|
||||
return createHash('md5').update(str).digest('hex')
|
||||
}
|
||||
@ -428,7 +436,7 @@ export default class Deezer implements StreamerWithLogin {
|
||||
trackTokenExpiry: number,
|
||||
format: DeezerFormat
|
||||
): Promise<string> {
|
||||
if (Date.now() - (this.renewTimestamp ?? 0) >= 3600 * 1000)
|
||||
if (this.#isSessionExpired())
|
||||
// renew license token
|
||||
await this.#apiCall('deezer.getUserData')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user