throw proper error for incompatibility on tidal, format qobuz

This commit is contained in:
aria
2024-05-02 07:24:18 -04:00
parent fbccef8399
commit 12c08e665f
2 changed files with 11 additions and 3 deletions

View File

@@ -139,13 +139,14 @@ export default class Qobuz implements StreamerWithLogin {
}
interface RawTrackFileResponse {
url: string
mime_type: string,
mime_type: string
sample: boolean
}
const trackFileResponse = <RawTrackFileResponse>(
await this.#getSigned('track/getFileUrl', params)
)
if (trackFileResponse.sample == true) throw new Error('Could not get non-sample file. Check your token.')
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,

View File

@@ -263,10 +263,11 @@ export default class Tidal implements Streamer {
tracks: tracksResponse.items.map(parseTrack)
}
}
async #getFileUrl(trackId: number | string, quality = 'HI_RES'): Promise<GetStreamResponse> {
async #getFileUrl(trackId: number | string, quality = 'LOSSLESS'): Promise<GetStreamResponse> {
interface PlaybackInfo {
manifest: string
manifestMimeType: string
audioQuality: 'LOW' | 'HIGH' | 'LOSSLESS' | 'HI_RES'
}
const playbackInfoResponse = <PlaybackInfo>await this.#get(
`tracks/${trackId}/playbackinfopostpaywall/v4`,
@@ -277,6 +278,12 @@ export default class Tidal implements Streamer {
prefetch: 'false'
}
)
if (
playbackInfoResponse.audioQuality == 'HIGH' ||
playbackInfoResponse.audioQuality == 'LOW'
) throw new Error('This ripper is incompatible with AAC codecs formats at the moment.')
const manifestStr = Buffer.from(playbackInfoResponse.manifest, 'base64').toString('utf-8')
interface Manifest {
mimeType: string