Created
May 24, 2017 15:02
-
-
Save blha303/9daa962b2bc6ea6b31b5f6e795db9b3f to your computer and use it in GitHub Desktop.
A tool to load a Bandcamp collection and print the urls for all included albums and tracks
This file contains hidden or 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
#!/usr/bin/env python3 | |
# A tool to load a Bandcamp collection and print the urls for all included albums and tracks | |
import requests | |
import click | |
import json | |
def get_data(user): | |
data = requests.get("https://bandcamp.com/{}".format(user)).text | |
if " item_details" not in data: | |
return False | |
return json.loads( | |
data.split(" item_details: ")[1].split("\n")[0][:-1] | |
) | |
@click.command() | |
@click.argument("user") | |
def print_bc_collection_urls(user): | |
for url in (item["item_url"] for item in get_data(user).values()): | |
click.echo(url) | |
if __name__ == "__main__": | |
print_bc_collection_urls() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment