Skip to content

Commit

Permalink
moved a method and a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkomarov committed Sep 5, 2024
1 parent d14119d commit 7bd6fa2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions exportify.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ let PlaylistExporter = {
saveAs(zip.generate({ type: "blob" }), "spotify_playlists.zip")
},

// take the playlist object and return an acceptable filename
fileName(playlist) {
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
},

// This is where the magic happens. The access token gives us permission to query this info from Spotify, and the
// playlist object gives us all the information we need to start asking for songs.
csvData(access_token, playlist) {
Expand Down Expand Up @@ -216,7 +221,7 @@ let PlaylistExporter = {
})
})

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

// Make queries for song audio features, 100 songs at a time. Happens after genre_promise has finished, to build in delay.
// Make queries for song audio features, 100 songs at a time.
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
Expand Down Expand Up @@ -272,11 +277,6 @@ let PlaylistExporter = {
let csv = ''; data.forEach(row => { csv += row.join(",") + "\n" })
return csv
})
},

// take the playlist object and return an acceptable filename
fileName(playlist) {
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
}
}

Expand Down

0 comments on commit 7bd6fa2

Please # to comment.