spotify: *refactoring

This commit is contained in:
2023-12-31 04:25:11 +01:00
parent b4710fe358
commit 680bc7d841
5 changed files with 41 additions and 41 deletions
+14 -9
View File
@@ -21,21 +21,26 @@ export default async function handler(
) {
try {
const song = await spotify.getCurrentSong()
if (!song || !song.isPlaying) {
if (!song.is_playing) {
return res.status(200).json({
nowplaying: false,
is_playing: false,
})
}
res.status(200).json({
nowplaying: true,
song: {
artist: song.artists.name,
title: song.title,
url: song.url,
is_playing: true,
name: song.name,
album: {
name: song.album.name,
image: song.album.image,
progress: song.progress,
length: song.length,
release: song.album.release_date,
},
artists: {
name: song.artists.name,
url: song.artists.url,
},
url: song.url,
progress: song.progress,
duration: song.duration,
})
} catch (error) {
res