Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Last active March 9, 2019 13:31
Show Gist options
  • Save loretoparisi/87a722692a444cb9e29e94d829a63d51 to your computer and use it in GitHub Desktop.
Save loretoparisi/87a722692a444cb9e29e94d829a63d51 to your computer and use it in GitHub Desktop.
Apple Music All Playlists
const URL = https://itunes.apple.com/us/curator/976439548#see-all/playlists
const NAME = "YOUR_NAME"
var playlist_names=$('.we-lockup__title')
var playlist_links = $('.targeted-link');
var apple_music_playlists=[];
playlist_names.each((index,elem) => {
var link = playlist_links[index];
var playlist = {};
playlist.url= $(link).attr('href')
playlist.name=$(elem).text().trim()
playlist.id=playlist.url.match(/(pl\..+)/)[0]
apple_music_playlists.push(playlist);
})
/**
* Save a text as file using HTML <a> temporary element and Blob
* @author Loreto Parisi
*/
var saveAsFile = function(fileName, fileContents) {
if (typeof(Blob) != 'undefined') { // Alternative 1: using Blob
var textFileAsBlob = new Blob([fileContents], {type: 'text/plain'});
var downloadLink = document.createElement("a");
downloadLink.download = fileName;
if (window.webkitURL != null) {
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
} else {
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = document.body.removeChild(event.target);
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
} else { // Alternative 2: using Data
var pp = document.createElement('a');
pp.setAttribute('href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(fileContents));
pp.setAttribute('download', fileName);
pp.onclick = document.body.removeChild(event.target);
pp.click();
}
} // saveAsFile
saveAsFile('apple_music_'+NAME+'.json', JSON.stringify(apple_music_playlists, null, 2));
@loretoparisi
Copy link
Author

other urls:

https://itunes.apple.com/us/curator/976439548#see-all/playlists
https://itunes.apple.com/us/curator/979231690#see-all/playlists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment