From f0dc2133340eeeed5f2728ee86b56115a9440b72 Mon Sep 17 00:00:00 2001 From: pavelkomarov Date: Tue, 10 Sep 2024 12:14:58 -0700 Subject: [PATCH] added back track ID at request of a user with a neat use case --- README.md | 1 + exportify.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97270dc..e16543a 100755 --- a/README.md +++ b/README.md @@ -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) diff --git a/exportify.js b/exportify.js index a3112fa..21857a6 100755 --- a/exportify.js +++ b/exportify.js @@ -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 => { @@ -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