Skip to content

Commit 7bd6fa2

Browse files
committed
moved a method and a comment
1 parent d14119d commit 7bd6fa2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

exportify.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ let PlaylistExporter = {
169169
saveAs(zip.generate({ type: "blob" }), "spotify_playlists.zip")
170170
},
171171

172+
// take the playlist object and return an acceptable filename
173+
fileName(playlist) {
174+
return playlist.name.replace(/[^a-z0-9\- ]/gi, '').replace(/[ ]/gi, '_').toLowerCase(); // /.../gi is a Perl-style modifier, g for global, meaning all matches replaced, i for case-insensitive
175+
},
176+
172177
// This is where the magic happens. The access token gives us permission to query this info from Spotify, and the
173178
// playlist object gives us all the information we need to start asking for songs.
174179
csvData(access_token, playlist) {
@@ -216,7 +221,7 @@ let PlaylistExporter = {
216221
})
217222
})
218223

219-
// Fetch album details, another wave of traffic, 20 albums at a time max
224+
// Fetch album details, another wave of traffic, 20 albums at a time max. Happens after genre_promise has finished, to build in delay.
220225
let album_promise = Promise.all([data_promise, genre_promise]).then(() => {
221226
album_ids = Array.from(album_ids) // chunk set of ids into 20s
222227
let album_chunks = []; while (album_ids.length) { album_chunks.push(album_ids.splice(0, 20)) }
@@ -230,7 +235,7 @@ let PlaylistExporter = {
230235
})
231236
})
232237

233-
// Make queries for song audio features, 100 songs at a time. Happens after genre_promise has finished, to build in delay.
238+
// Make queries for song audio features, 100 songs at a time.
234239
let features_promise = Promise.all([data_promise, genre_promise, album_promise]).then(values => {
235240
let data = values[0]
236241
let songs_promises = data.map((chunk, i) => { // remember data is an array of arrays, each subarray 100 tracks
@@ -272,11 +277,6 @@ let PlaylistExporter = {
272277
let csv = ''; data.forEach(row => { csv += row.join(",") + "\n" })
273278
return csv
274279
})
275-
},
276-
277-
// take the playlist object and return an acceptable filename
278-
fileName(playlist) {
279-
return playlist.name.replace(/[^a-z0-9\- ]/gi, '').replace(/[ ]/gi, '_').toLowerCase(); // /.../gi is a Perl-style modifier, g for global, meaning all matches replaced, i for case-insensitive
280280
}
281281
}
282282

0 commit comments

Comments
 (0)