From 5a702afcf971128e57e1384dcfce1a667e2ce4fc Mon Sep 17 00:00:00 2001 From: aria blue Date: Thu, 18 Apr 2024 20:52:41 -0400 Subject: [PATCH] qobuz sample erroring --- src/streamers/qobuz/main.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/streamers/qobuz/main.ts b/src/streamers/qobuz/main.ts index ff21429..0b2b011 100644 --- a/src/streamers/qobuz/main.ts +++ b/src/streamers/qobuz/main.ts @@ -91,20 +91,19 @@ export default class Qobuz implements StreamerWithLogin { } async login(username: string, password: string) { - if (!this.token) { - const params: { [key: string]: string } = { - username, - password: md5(password), - extra: 'partner', - app_id: this.appId - } - - interface LoginResponse { - user_auth_token: string - } - const loginResponse = await this.#getSigned('user/login', params) - this.token = loginResponse.user_auth_token + if (this.token) return + const params: { [key: string]: string } = { + username, + password: md5(password), + extra: 'partner', + app_id: this.appId } + + interface LoginResponse { + user_auth_token: string + } + const loginResponse = await this.#getSigned('user/login', params) + this.token = loginResponse.user_auth_token } async search(query: string, limit = 10): Promise { @@ -140,11 +139,13 @@ export default class Qobuz implements StreamerWithLogin { } interface RawTrackFileResponse { url: string - mime_type: string + mime_type: string, + sample: boolean } const trackFileResponse = ( await this.#getSigned('track/getFileUrl', params) ) + if (trackFileResponse.sample == true) throw new Error('Could not get non-sample file. Check your token.') const streamResponse = await fetch(trackFileResponse.url) return { mimeType: trackFileResponse.mime_type,