Shows song title instead of "Unknown Album" on singles

This commit is contained in:
Wizzard 2023-07-28 17:25:14 -04:00
parent 92aa257520
commit 63123f6e74
1 changed files with 9 additions and 3 deletions

12
main.js
View File

@ -56,7 +56,7 @@ async function updateStatus() {
} }
await rp.setActivity({ await rp.setActivity({
largeImageKey: data.album !== "Unknown Album" ? data.cover : "default_cover", largeImageKey: data.album !== data.trackName ? data.cover : "default_cover",
largeImageText: `${data.playcount} plays.`, largeImageText: `${data.playcount} plays.`,
smallImageKey: data.whenScrobbled ? "playing" : "stopped", smallImageKey: data.whenScrobbled ? "playing" : "stopped",
smallImageText: data.scrobbleStatus, smallImageText: data.scrobbleStatus,
@ -137,9 +137,14 @@ async function fetchCurrentScrobble(user) {
let images = lastTrack.recenttracks.track[0].image; let images = lastTrack.recenttracks.track[0].image;
let coverURL = images && images[images.length - 1]["#text"].trim() ? images[images.length - 1]["#text"].trim() : "default_cover"; let coverURL = images && images[images.length - 1]["#text"].trim() ? images[images.length - 1]["#text"].trim() : "default_cover";
let albumName = lastTrack.recenttracks.track[0].album["#text"];
if (!albumName) {
albumName = lastTrackName;
}
const data = { const data = {
artist: lastArtist, artist: lastArtist,
album: lastTrack.recenttracks.track[0].album["#text"] || "Unknown Album", album: albumName,
trackName: lastTrackName, trackName: lastTrackName,
playcount: playcount, playcount: playcount,
scrobbles: lastTrack.recenttracks["@attr"].total, scrobbles: lastTrack.recenttracks["@attr"].total,
@ -153,4 +158,5 @@ async function fetchCurrentScrobble(user) {
console.error("Failed to fetch current scrobble for track: " + lastTrackName + " by artist: " + lastArtist, error); console.error("Failed to fetch current scrobble for track: " + lastTrackName + " by artist: " + lastArtist, error);
return null; return null;
} }
} }