Skip to content

Instantly share code, notes, and snippets.

@SakiiR
Last active October 9, 2024 09:24
Show Gist options
  • Save SakiiR/c3777b4e9e1da7047e930b4d05aadb0f to your computer and use it in GitHub Desktop.
Save SakiiR/c3777b4e9e1da7047e930b4d05aadb0f to your computer and use it in GitHub Desktop.
Bandcamp - Download wishlist album links to json
// bandcamp-dl -f -r -u -d --base-dir . `cat ~/Downloads/bandcamp-wishlist.json|jq -r '.[]'|tr '\n' ' '`
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function download(jsonContent) {
var element = document.createElement('a');
element.setAttribute('href', 'data:application/json;charset=utf-8,' + encodeURIComponent(jsonContent));
element.setAttribute('download', "bandcamp-wishlist.json");
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
async function main() {
const albums = new Set();
const $btn = $('button.show-more');
const count = parseInt(Array.from($('ol#grid-tabs > li > span > span.count')).filter(item => item.parentElement.innerText.includes("wishlist"))[0].innerText);
const SLEEP_TIME = 500;
while (albums.size < count) {
Array.from($$('.collection-title-details > a')).map((item) => albums.add(item.href))
$btn.click();
await sleep(SLEEP_TIME);
console.log(`next page ${albums.size} / ${count}`);
}
download(JSON.stringify(Array.from(albums)));
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment