Last active
September 29, 2024 04:31
-
-
Save hennzen/dc2b7bb76ce5507063f6c5e60c68886a to your computer and use it in GitHub Desktop.
Export Shazam list to JSON format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS-Console script to export song name, artist and cover image URL to a JSON format | |
// Order of results is in ascending date order. If you want to change that, delete line with '.reverse()' | |
// The result is copied to your clipboard | |
// | |
// 1. Open https://www.shazam.com/myshazam and login | |
// 2. Scroll down to the end of your list, so that *all* songs are loaded | |
// 3. Open Developer console with F12 | |
// 4. Copy paste this code to the JS-console and hit Enter | |
// 5. Paste the result to your favorite text editor. Voilà. | |
// Output JSON looks like | |
// { | |
// "meta": { | |
// "scriptUrl": "https://gist.github.com/hennzen/dc2b7bb76ce5507063f6c5e60c68886a", | |
// "scriptRevision": "0.0.3", | |
// "listCreated": "2020-09-27T07:40:06.184Z" | |
// }, | |
// "shazamItems": [ | |
// { | |
// "no": 1, | |
// "title": "Dancing With The Damned", | |
// "artist": "Killing Mood", | |
// "cover": "https://images.shazam.com/coverart/t50270807-b333557118_s400.jpg", | |
// "availableOnAppleMusicPlay": true | |
// } | |
// ] | |
// } | |
copy ({ | |
meta: { | |
scriptUrl: "https://gist.github.com/hennzen/dc2b7bb76ce5507063f6c5e60c68886a", | |
scriptRevision: "0.0.3", | |
listCreated: new Date().toISOString() | |
}, | |
shazamItems: Array.from(document.querySelectorAll('.shazams-content ul.panel-bd.panel-bd-wide')) | |
.reverse() // delete this line for date descending order | |
.map((item, index) => ({ | |
no: index + 1, | |
title: item.querySelector('.title').innerText, | |
artist: item.querySelector('.artist').innerText, | |
cover: item.querySelector('.image.album-art').style['background-image'].match(/"(.*?)"/)[1], | |
availableOnAppleMusicPlay: item.querySelector('article').getAttribute("data-shz-applemusicplay-id").length ? true: false | |
})) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did a slight tweak to the selector and was glad to find the script works:
https://gist.github.com/g2p/1e45df5c70a22e2c01edc91978d56896/revisions