Skip to content

Instantly share code, notes, and snippets.

@vincerubinetti
Created February 23, 2021 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincerubinetti/51c0cf8b9662c2d5b61ede5bef04d3e3 to your computer and use it in GitHub Desktop.
Save vincerubinetti/51c0cf8b9662c2d5b61ede5bef04d3e3 to your computer and use it in GitHub Desktop.
// 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