Created
February 23, 2021 04:09
-
-
Save vincerubinetti/51c0cf8b9662c2d5b61ede5bef04d3e3 to your computer and use it in GitHub Desktop.
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
// go to Bandcamp edit album page, open dev console (f12), paste and run | |
function download() { | |
const sel = (selector, base = document) => base.querySelectorAll(selector); | |
const get = (selector, base) => { | |
elements = sel(selector, base); | |
element = elements[0] || {}; | |
return element.value || element.innerText || ""; | |
}; | |
const title = get("[name='album.title']"); | |
const date = get("[name='album.release_date']"); | |
const about = get("[name='album.about']"); | |
const credits = get("[name='album.credits']"); | |
const rows = sel("li.track"); | |
const tracks = []; | |
for (const row of rows) { | |
const title = get("[name*='track.title']", row); | |
const about = get("[name*='track.about']", row); | |
const lyrics = get("[name*='track.lyrics']", row); | |
const credits = get("[name*='track.credits']", row); | |
tracks.push({ title, about, lyrics, credits }); | |
} | |
const data = { title, date, about, credits, tracks }; | |
const blob = new Blob([JSON.stringify(data)], { type: "application/json" }); | |
const url = window.URL.createObjectURL(blob); | |
const link = document.createElement("a"); | |
document.body.appendChild(link); | |
link.href = url; | |
link.download = title.toLowerCase(); | |
link.click(); | |
} | |
download(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment