From 94c5134af27abd42f2fe9fcca4dd73481f7291d9 Mon Sep 17 00:00:00 2001 From: aria blue Date: Sat, 13 Apr 2024 13:38:09 -0400 Subject: [PATCH] fix coverless album bug tidal, bump version --- package.json | 2 +- src/streamers/tidal/parse.ts | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0f927ee..5326921 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lucida", - "version": "1.2.8", + "version": "1.2.9", "description": "A modular music downloader tool", "main": "build/index.js", "type": "module", diff --git a/src/streamers/tidal/parse.ts b/src/streamers/tidal/parse.ts index 1469ae5..6ffb797 100644 --- a/src/streamers/tidal/parse.ts +++ b/src/streamers/tidal/parse.ts @@ -9,7 +9,10 @@ export interface RawArtist { } export function parseArtist(raw: RawArtist): Artist { - const picturePath = raw?.picture?.replace(/-/gm, '/') + let picturePath + + if (raw?.picture != null) picturePath = raw?.picture?.replace(/-/gm, '/') + else picturePath = null const artist: Artist = { id: raw.id, url: raw.url ?? `https://www.tidal.com/artist/${raw.id}`, @@ -37,12 +40,20 @@ export interface RawAlbum { } export function parseAlbum(raw: RawAlbum): Album { - const coverPath = raw.cover.replace(/-/gm, '/') + let coverPath + + if (raw.cover) coverPath = raw.cover.replace(/-/gm, '/') + else coverPath = null + const album: Album = { id: raw.id, url: raw.url ?? `https://tidal.com/browse/album/${raw.id}`, title: raw.title, - coverArtwork: [ + coverArtwork: [] + } + + if (coverPath) + album.coverArtwork = [ { url: `https://resources.tidal.com/images/${coverPath}/160x160.jpg`, width: 160, @@ -59,7 +70,6 @@ export function parseAlbum(raw: RawAlbum): Album { height: 1280 } ] - } if (raw.upc) album.upc = raw.upc if (raw.artists) album.artists = raw.artists.map(parseArtist) if (raw.numberOfTracks) album.trackCount = raw.numberOfTracks