From de9adfc5bf2f876090727c70d9ab6c1c8aff2f3e Mon Sep 17 00:00:00 2001 From: KGT1 Date: Sun, 17 Jan 2021 04:30:28 +0100 Subject: [PATCH] add graceful fallback to song image if no album image is found --- src/playbackmanager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/playbackmanager.js b/src/playbackmanager.js index b04761e..d09888f 100644 --- a/src/playbackmanager.js +++ b/src/playbackmanager.js @@ -75,7 +75,7 @@ function startPlaying (voiceconnection = discordclientmanager.getDiscordClient() async function spawnPlayMessage (message) { const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId()); - const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId, { type: "Primary" }); + const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" }); try { interactivemsghandler.init(message, itemIdDetails.Name, itemIdDetails.Artists[0] || "VA", imageURL, `${jellyfinClientManager.getJellyfinClient().serverAddress()}/web/index.html#!/details?id=${itemIdDetails.AlbumId}`, @@ -97,7 +97,7 @@ async function spawnPlayMessage (message) { async function updatePlayMessage () { if (getItemId() !== undefined) { const itemIdDetails = await jellyfinClientManager.getJellyfinClient().getItem(jellyfinClientManager.getJellyfinClient().getCurrentUserId(), getItemId()); - const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId, { type: "Primary" }); + const imageURL = await jellyfinClientManager.getJellyfinClient().getImageUrl(itemIdDetails.AlbumId || getItemId(), { type: "Primary" }); interactivemsghandler.updateCurrentSongMessage(itemIdDetails.Name, itemIdDetails.Artists[0] || "VA", imageURL, `${jellyfinClientManager.getJellyfinClient().serverAddress()}/web/index.html#!/details?id=${itemIdDetails.AlbumId}`, itemIdDetails.RunTimeTicks, currentPlayingPlaylistIndex + 1, currentPlayingPlaylist.length); }