From e30a3c1d8ea703be11259e33dce4bde84ed663c7 Mon Sep 17 00:00:00 2001 From: busybox11 Date: Wed, 28 Aug 2024 01:02:32 +0200 Subject: [PATCH] playing: Initial podcasts support --- assets/js/playing.js | 12 ++++++++---- miniplayer.php | 2 +- playing.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/assets/js/playing.js b/assets/js/playing.js index ce9221c..cc50be4 100644 --- a/assets/js/playing.js +++ b/assets/js/playing.js @@ -80,7 +80,9 @@ document.addEventListener('alpine:init', x => { await this.refreshToken(); } - const response = await spotifyApi.getMyCurrentPlaybackState(); + const response = await spotifyApi.getMyCurrentPlaybackState({ + additional_types: "episode" + }); if (response) { this.handleChange(response); } @@ -90,15 +92,17 @@ document.addEventListener('alpine:init', x => { this.lastPlaybackObj = this.playbackObj; this.playbackObj = obj; + const artists = this.playbackObj.item?.artists || [{ name: this.playbackObj.item?.show?.publisher }] + if (this.playbackObj.item?.name) { - document.title = `${this.playbackObj.item?.name} - ${this.playbackObj.item?.artists[0].name} - NowPlaying`; + document.title = `${this.playbackObj.item?.name} - ${artists[0].name} - NowPlaying`; } // Fetch album art - const imgsArr = this.playbackObj.item?.album?.images; + const imgsArr = this.playbackObj.item?.album?.images || this.playbackObj.item?.images; const targetImg = (useSmallAlbumCover) ? imgsArr[imgsArr.length - 2]?.url : imgsArr[0]?.url; - const lastImgsArr = this.lastPlaybackObj.item?.album?.images; + const lastImgsArr = this.lastPlaybackObj.item?.album?.images || this.lastPlaybackObj.item?.images; if (lastImgsArr === undefined) { this.targetImg = targetImg; return; diff --git a/miniplayer.php b/miniplayer.php index 8d5ec45..823e1ef 100644 --- a/miniplayer.php +++ b/miniplayer.php @@ -93,7 +93,7 @@ class="text-3xl font-bold text-pretty" :class="{ }">

diff --git a/playing.php b/playing.php index f09ba4f..46e7bfc 100644 --- a/playing.php +++ b/playing.php @@ -154,7 +154,7 @@ class="absolute bottom-6 left-6 z-30 flex flex-row bg-black/20 border-2 border-w

-