From c5225f96ac68788a4289598869619eedefeeabed Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Fri, 27 Oct 2023 15:59:59 +0200 Subject: [PATCH] fix(stats): return correctly parsed spotify song --- src/stats.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stats.ts b/src/stats.ts index 79d9b3dd64f..50574f5cfbd 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -55,9 +55,10 @@ class Stats extends Core { } const ytCurrentSong = Object.values(songs.isPlaying).find(o => o) ? get(JSON.parse(songs.currentSong), 'title', null) : null; - let spotifyCurrentSong: null | string = get(JSON.parse(spotify.currentSong), 'song', '') + ' - ' + get(JSON.parse(spotify.currentSong), 'artist', ''); - if (spotifyCurrentSong.trim().length === 1 /* '-' */ || get(JSON.parse(spotify.currentSong), 'is_playing', false)) { - spotifyCurrentSong = null; + const spotifySongParsed = JSON.parse(spotify.currentSong); + let spotifyCurrentSong: null | string = null; + if (spotifySongParsed && spotifySongParsed.is_playing) { + spotifyCurrentSong = `${spotifySongParsed.song} - ${spotifySongParsed.artist}`; } const broadcasterType = variables.get('services.twitch.broadcasterType') as string;