Last active 1535292882

A tool to load a Bandcamp collection and print the urls for all included albums and tracks

Steven Smith revised this gist 1495638162. Go to revision

1 file changed, 22 insertions

bc_col.py(file created)

@@ -0,0 +1,22 @@
1 + #!/usr/bin/env python3
2 + # A tool to load a Bandcamp collection and print the urls for all included albums and tracks
3 + import requests
4 + import click
5 + import json
6 +
7 + def get_data(user):
8 + data = requests.get("https://bandcamp.com/{}".format(user)).text
9 + if " item_details" not in data:
10 + return False
11 + return json.loads(
12 + data.split(" item_details: ")[1].split("\n")[0][:-1]
13 + )
14 +
15 + @click.command()
16 + @click.argument("user")
17 + def print_bc_collection_urls(user):
18 + for url in (item["item_url"] for item in get_data(user).values()):
19 + click.echo(url)
20 +
21 + if __name__ == "__main__":
22 + print_bc_collection_urls()
Newer Older