improve tidal logs, fix soundcloud (for real this time)

This commit is contained in:
aria blue
2024-04-11 17:04:24 -04:00
parent 7375e0e9c6
commit 9bc40e00c2
2 changed files with 9 additions and 9 deletions

View File

@@ -66,7 +66,7 @@ export async function parseAlbum(raw: RawAlbum): Promise<Album> {
}
if (raw.tracks?.[0]?.artwork_url != undefined) {
album.coverArtwork = [
await parseCoverArtwork(raw.tracks[0].artwork_url.replace('-large', '-original'))
await parseCoverArtwork(raw?.tracks?.[0]?.artwork_url)
]
}
return album
@@ -95,7 +95,7 @@ export async function parseTrack(raw: RawTrack): Promise<Track> {
}
if (raw?.artwork_url != undefined) {
track.coverArtwork = [await parseCoverArtwork(raw?.artwork_url?.replace('-large', '-original'))]
track.coverArtwork = [await parseCoverArtwork(raw?.artwork_url)]
}
return track

View File

@@ -51,8 +51,8 @@ export default class Tidal implements Streamer {
if (!this.refreshToken) return
if (await this.sessionValid()) return
const success = await this.refresh()
if (success) console.log(`Refreshed tokens successfully`)
else console.log(`Failed to refresh tokens, this could be a bad sign`)
if (success) console.log(`[tidal] Refreshed tokens successfully`)
else console.log(`[tidal] Failed to refresh tokens, this could be a bad sign`)
}
getReady()
}
@@ -86,15 +86,15 @@ export default class Tidal implements Streamer {
const sessionValid = await this.sessionValid()
if (json.status == 401 && !sessionValid) {
this.failedAuth = !(await this.refresh())
console.log('Refreshed tokens')
console.log('[tidal] Refreshed tokens')
if (this.failedAuth) {
throw new Error('Auth failed. Try getting new tokens.')
}
return this.#get(url, params)
}
console.error('Tidal error response:', json)
console.error('[tidal] Tidal error response:', json)
} catch (error) {
console.error('Tidal error response:', errMsg)
console.error('[tidal] Tidal error response:', errMsg)
}
throw new Error(`Fetching ${url} from Tidal failed with status code ${response.status}.`)
}
@@ -146,9 +146,9 @@ export default class Tidal implements Streamer {
this.refreshToken = loginData.refresh_token
this.expires = Date.now() + loginData.expires_in * 1000
console.log('Using the following new config:', this.getCurrentConfig())
console.log('[tidal] Using the following new config:', this.getCurrentConfig())
}
console.log(`Log in at ${linkUrl}`)
console.log(`[tidal] Log in at ${linkUrl}`)
checkToken()
return linkUrl
}