Skip to content

Commit

Permalink
fix: spotify embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsumara committed Jan 23, 2023
1 parent 1467505 commit aad9857
Show file tree
Hide file tree
Showing 3 changed files with 517 additions and 246 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ let songArrayAge = 0;
app.get('/top4', async (req, res) => {
if (Date.now() - songArrayAge > 86400000) {
let data = await spot.getTracks('https://open.spotify.com/playlist/37i9dQZF1EpwA0Eb3mMXw4');
songArray = data.sort(() => 0.5 - Math.random()).slice(0, 4).map(song => { return song.id });
songArrayAge = Date.now()
console.log(data);
songArray = data.sort(() => Math.random() - 0.5).slice(0, 4).map(song => { return song.uri.slice(14) });
console.log(songArray);
songArrayAge = Date.now();
}
res.send(songArray);
});
Expand Down
Loading

0 comments on commit aad9857

Please sign in to comment.