From c5ed329e49b1b14db14dd920e85035cbb06c9390 Mon Sep 17 00:00:00 2001 From: aria Date: Mon, 29 Jul 2024 19:30:40 -0400 Subject: [PATCH] bug fix for tidal account checker --- src/streamers/tidal/main.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/streamers/tidal/main.ts b/src/streamers/tidal/main.ts index 8a9ec25..1b2eac2 100644 --- a/src/streamers/tidal/main.ts +++ b/src/streamers/tidal/main.ts @@ -42,6 +42,8 @@ interface LoginData { interface SessionData { countryCode: string userId: number + status?: number + userMessage?: string } interface SubscriptionData { @@ -419,7 +421,16 @@ export default class Tidal implements Streamer { } } async getAccountInfo(): Promise { - if (!this.userId) await this.getCountryCode() + if (this.userId == undefined || this.countryCode == undefined) { + if (Date.now() > this.expires) await this.refresh() + const sessionResponse = await fetch('https://api.tidal.com/v1/sessions', { + headers: this.headers() + }) + const sessionData = await sessionResponse.json() + + this.userId = sessionData.userId + this.countryCode = sessionData.countryCode + } const subscription = ( await this.#get(`users/${this.userId}/subscription`, {}, TIDAL_SUBSCRIPTION_BASE) )