🐛 (spotify) fix get number of tracks from playlist
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const PLAYLIST_IDS = [
|
||||
const PLAYLIST_LINKS = [
|
||||
'spotify:playlist:0vvXsWCC9xrXsKd4FyS8kM',
|
||||
'spotify:playlist:5G1gAuXjmJHgEoI7XzrXOP',
|
||||
'spotify:playlist:5OJs7eATLrvZ2Ea9als3lK',
|
||||
@@ -40,9 +40,15 @@ export const redirectToSpotifyConnect = () => {
|
||||
}
|
||||
|
||||
export const playOnSpotify = async (token: string, deviceId: string) => {
|
||||
const playlistId = PLAYLIST_IDS[random(PLAYLIST_IDS.length - 1)]
|
||||
const playlistId = PLAYLIST_LINKS[random(PLAYLIST_LINKS.length - 1)]
|
||||
.split(':')
|
||||
.pop()
|
||||
|
||||
const trackResult = await fetch(
|
||||
`https://api.spotify.com/v1/playlists/${playlistId}/tracks?fields=items(track(name))`
|
||||
`https://api.spotify.com/v1/playlists/${playlistId}/tracks?fields=items(track(name))`,
|
||||
{
|
||||
...getHeaders(token)
|
||||
}
|
||||
)
|
||||
const tracks = (await trackResult.json()) as SpotifyTracks
|
||||
|
||||
@@ -52,7 +58,7 @@ export const playOnSpotify = async (token: string, deviceId: string) => {
|
||||
method: 'PUT',
|
||||
...getHeaders(token),
|
||||
body: JSON.stringify({
|
||||
context_uri: PLAYLIST_IDS[random(PLAYLIST_IDS.length - 1)],
|
||||
context_uri: PLAYLIST_LINKS[random(PLAYLIST_LINKS.length - 1)],
|
||||
offset: {
|
||||
position: random(tracks?.items?.length || 0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user