Add the tracks with the given URIs to the playlist with the given playlist ID
1
import { Client } from '[email protected]';
2
3
type Spotify = {
4
token: string;
5
}
6
7
export async function main(
8
spotifyCredentials: Spotify,
9
playlistId: string,
10
trackUris: string[],
11
position?: number
12
) {
13
if (trackUris.length === 0) {
14
console.log('Zero tracks provided, exiting');
15
return;
16
17
18
const client = new Client({
19
token: spotifyCredentials.token
20
});
21
22
console.log(`Adding ${trackUris.length} tracks to playlist '${playlistId}'`);
23
24
await client.playlists.addItems(playlistId, trackUris, position);
25
26