From 8c15b0b708d90ae4b4c866c885cfa8cd4bc0b32e Mon Sep 17 00:00:00 2001 From: Thomas Amland Date: Thu, 24 Oct 2024 12:23:43 +0200 Subject: [PATCH] add description, lastfm and musicbrainz url to album page --- src/library/album/AlbumDetails.vue | 55 ++++++++++++++++++++++-------- src/shared/api.ts | 15 ++++++-- 2 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/library/album/AlbumDetails.vue b/src/library/album/AlbumDetails.vue index db5e27d..591bea6 100644 --- a/src/library/album/AlbumDetails.vue +++ b/src/library/album/AlbumDetails.vue @@ -7,21 +7,42 @@ -

- by - - • {{ album.year }} - • - +

+
+ by + + , + + {{ artist.name }} + + +
+ • {{ album.year }} + +
+ + + + + + +
+
+ +
+ + + + {{ genre }} + -

-
+
+ + + {{ album.description }} + + +
Play @@ -50,9 +71,15 @@ import TrackList from '@/library/track/TrackList.vue' import { Album } from '@/shared/api' import { useFavouriteStore } from '@/library/favourite/store' + import IconLastFm from '@/shared/components/IconLastFm.vue' + import IconMusicBrainz from '@/shared/components/IconMusicBrainz.vue' + import OverflowFade from '@/shared/components/OverflowFade.vue' export default defineComponent({ components: { + OverflowFade, + IconMusicBrainz, + IconLastFm, TrackList, }, props: { diff --git a/src/shared/api.ts b/src/shared/api.ts index 59a2b63..e854a6a 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -33,11 +33,14 @@ export interface Genre { export interface Album { id: string name: string + description?: string artists: {name: string, id: string}[] year: number favourite: boolean genres: Genre[] image?: string + lastFmUrl?: string + musicBrainzUrl?: string tracks?: Track[] } @@ -244,8 +247,11 @@ export class API { async getAlbumDetails(id: string): Promise { const params = { id } - const data = await this.fetch('rest/getAlbum', params) - return this.normalizeAlbum(data.album) + const [info, info2] = await Promise.all([ + this.fetch('rest/getAlbum', params), + this.fetch('rest/getAlbumInfo2', params), + ]) + return this.normalizeAlbum({ ...info.album, ...info2.albumInfo }) } async getPlaylists() { @@ -549,6 +555,7 @@ export class API { return { id: item.id, name: item.name, + description: (item.notes || '').replace(/]*>.*?<\/a>/gm, ''), artists: item.artists?.length ? item.artists : [{ id: item.artistId, name: item.artist }], @@ -556,6 +563,10 @@ export class API { year: item.year || 0, favourite: !!item.starred, genres: this.normalizeGenres(item), + lastFmUrl: item.lastFmUrl, + musicBrainzUrl: item.musicBrainzId + ? `https://musicbrainz.org/album/${item.musicBrainzId}` + : undefined, tracks: (item.song || []).map(this.normalizeTrack, this) } }