Skip to content

Commit

Permalink
added back track ID at request of a user with a neat use case
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkomarov committed Sep 10, 2024
1 parent b4cf03e commit f0dc213
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This is a hard fork of [the original Exportify repo](https://github.com/watsonbo

Track data is exported in [CSV](http://en.wikipedia.org/wiki/Comma-separated_values) format with the following fields:

- [Track ID](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids)
- Track Name
- Album Name
- Artist Name(s)
Expand Down
4 changes: 2 additions & 2 deletions exportify.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ let PlaylistExporter = {
let features_promise = Promise.all([data_promise, genre_promise, album_promise]).then(values => {
let data = values[0]
let songs_promises = data.map((chunk, i) => { // remember data is an array of arrays, each subarray 100 tracks
let ids = chunk.map(song => song.shift()).join(','); // the id lives in the first position; throw away once grabbed
let ids = chunk.map(song => song[0]).join(','); // the id lives in the first position
return utils.apiCall('https://api.spotify.com/v1/audio-features?ids='+ids , access_token, 100*i);
})
return Promise.all(songs_promises).then(responses => {
Expand Down Expand Up @@ -272,7 +272,7 @@ let PlaylistExporter = {
features = features.flat() // get rid of the batch dimension (only 100 songs per call)
data.forEach((row, i) => features[i]?.forEach(feat => row.push(feat)))
// make a string
let csv = "Track Name,Album Name,Artist Name(s),Release Date,Duration (ms),Popularity,Added By,Added At,Genres,Record Label,\
let csv = "Track ID,Track Name,Album Name,Artist Name(s),Release Date,Duration (ms),Popularity,Added By,Added At,Genres,Record Label,\
Danceability,Energy,Key,Loudness,Mode,Speechiness,Acousticness,Instrumentalness,Liveness,Valence,Tempo,Time Signature\n"
data.forEach(row => { csv += row.join(",") + "\n" })
return csv
Expand Down

0 comments on commit f0dc213

Please sign in to comment.