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

View File

@@ -51,8 +51,8 @@ export default class Tidal implements Streamer {
if (!this.refreshToken) return if (!this.refreshToken) return
if (await this.sessionValid()) return if (await this.sessionValid()) return
const success = await this.refresh() const success = await this.refresh()
if (success) console.log(`Refreshed tokens successfully`) if (success) console.log(`[tidal] Refreshed tokens successfully`)
else console.log(`Failed to refresh tokens, this could be a bad sign`) else console.log(`[tidal] Failed to refresh tokens, this could be a bad sign`)
} }
getReady() getReady()
} }
@@ -86,15 +86,15 @@ export default class Tidal implements Streamer {
const sessionValid = await this.sessionValid() const sessionValid = await this.sessionValid()
if (json.status == 401 && !sessionValid) { if (json.status == 401 && !sessionValid) {
this.failedAuth = !(await this.refresh()) this.failedAuth = !(await this.refresh())
console.log('Refreshed tokens') console.log('[tidal] Refreshed tokens')
if (this.failedAuth) { if (this.failedAuth) {
throw new Error('Auth failed. Try getting new tokens.') throw new Error('Auth failed. Try getting new tokens.')
} }
return this.#get(url, params) return this.#get(url, params)
} }
console.error('Tidal error response:', json) console.error('[tidal] Tidal error response:', json)
} catch (error) { } 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}.`) 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.refreshToken = loginData.refresh_token
this.expires = Date.now() + loginData.expires_in * 1000 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() checkToken()
return linkUrl return linkUrl
} }