Skip to content

Commit f0dc213

Browse files
committed
added back track ID at request of a user with a neat use case
1 parent b4cf03e commit f0dc213

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This is a hard fork of [the original Exportify repo](https://github.com/watsonbo
1212

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

15+
- [Track ID](https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids)
1516
- Track Name
1617
- Album Name
1718
- Artist Name(s)

exportify.js

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

0 commit comments

Comments
 (0)