mirror of
https://codeberg.org/lucida/lucida.git
synced 2026-11-17 00:57:25 -05:00
qobuz sample erroring
This commit is contained in:
@@ -91,7 +91,7 @@ export default class Qobuz implements StreamerWithLogin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async login(username: string, password: string) {
|
async login(username: string, password: string) {
|
||||||
if (!this.token) {
|
if (this.token) return
|
||||||
const params: { [key: string]: string } = {
|
const params: { [key: string]: string } = {
|
||||||
username,
|
username,
|
||||||
password: md5(password),
|
password: md5(password),
|
||||||
@@ -105,7 +105,6 @@ export default class Qobuz implements StreamerWithLogin {
|
|||||||
const loginResponse = <LoginResponse>await this.#getSigned('user/login', params)
|
const loginResponse = <LoginResponse>await this.#getSigned('user/login', params)
|
||||||
this.token = loginResponse.user_auth_token
|
this.token = loginResponse.user_auth_token
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async search(query: string, limit = 10): Promise<SearchResults> {
|
async search(query: string, limit = 10): Promise<SearchResults> {
|
||||||
if (!this.token) throw new Error('Not logged in.')
|
if (!this.token) throw new Error('Not logged in.')
|
||||||
@@ -140,11 +139,13 @@ export default class Qobuz implements StreamerWithLogin {
|
|||||||
}
|
}
|
||||||
interface RawTrackFileResponse {
|
interface RawTrackFileResponse {
|
||||||
url: string
|
url: string
|
||||||
mime_type: string
|
mime_type: string,
|
||||||
|
sample: boolean
|
||||||
}
|
}
|
||||||
const trackFileResponse = <RawTrackFileResponse>(
|
const trackFileResponse = <RawTrackFileResponse>(
|
||||||
await this.#getSigned('track/getFileUrl', params)
|
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)
|
const streamResponse = await fetch(trackFileResponse.url)
|
||||||
return {
|
return {
|
||||||
mimeType: trackFileResponse.mime_type,
|
mimeType: trackFileResponse.mime_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user