├── bandcamp_api ├── __init__.py ├── TODO.md ├── artist.py ├── bandcampjson.py ├── genres.py ├── label.py ├── track.py ├── search.py ├── bandcamp_api.py ├── album.py ├── daily.py └── homepage.py ├── setup.py ├── README.md ├── .gitignore └── LICENSE /bandcamp_api/__init__.py: -------------------------------------------------------------------------------- 1 | from .bandcamp_api import Bandcamp -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import * 2 | 3 | setup( 4 | name="bandcamp_api", 5 | version="0.2.2", 6 | description="Obtains information from bandcamp.com", 7 | author="RustyRin", 8 | packages=['bandcamp_api'], 9 | url="https://github.com/RustyRin/bandcamp-api/", 10 | install_requires=["setuptools", "beautifulsoup4", "demjson3", 'html5lib', 'lxml', "requests"], 11 | keywords=["api", "bandcamp"], 12 | zip_safe=False 13 | ) 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bandcamp-api 2 | A simple way to get info from Bandcamp 3 | 4 | This was based on and inspired by the work at [bandcamp-dl](https://github.com/iheanyi/bandcamp-dl) 5 | Thank you for making my work much easier! 6 | 7 | #### Installation 8 | `pip install bandcamp-api` 9 | 10 | #### Basic Use 11 | ```python 12 | from bandcamp_api import Bandcamp 13 | 14 | bc = Bandcamp() 15 | 16 | album = bc.get_album(album_url="https://c418.bandcamp.com/album/minecraft-volume-alpha") 17 | 18 | print("Album title:", album.album_title) 19 | ``` 20 | 21 | For more information on the functions available see the [functions wiki](https://github.com/RustyRin/bandcamp-api/wiki/Functions) or the [object wiki](https://github.com/RustyRin/bandcamp-api/wiki/Bandcamp-api-Objects) 22 | -------------------------------------------------------------------------------- /bandcamp_api/TODO.md: -------------------------------------------------------------------------------- 1 | # Things that I need to add 2 | 3 | - Main Page 4 | - Get live streams 5 | - Get information about a live stream 6 | 7 | - Merch 8 | - Given a artist URL 9 | - Get all merch items 10 | - Get price, currency 11 | - Get units sold, and total stock 12 | - Get all pictures 13 | - get shipping time 14 | - Get merch type ('vinyl', 'T-Shirt/Shirt') 15 | - when on the merch page, clicking on the merch brings you to the album page, search for the title of the merch, then get info 16 | - Artist Community 17 | - Get community posts and things with community posts 18 | - didnt do it cause it seemed small 19 | - Have to find an artist that uses community posts and has an active community interaction 20 | - Artist Subscription 21 | - Im pretty sure artists also have subscriptions 22 | - Label profile picture 23 | - Get Bandcamp Daily tracks from the body 24 | - The tracks cannot be scraped 25 | - they are rendered by js 26 | - maybe someway in the future i can scrape the rendered js -------------------------------------------------------------------------------- /bandcamp_api/artist.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | 4 | class Artist: 5 | def __init__(self, artist_id: int): 6 | self.artist_title = "" 7 | self.artist_id = 0 8 | self.artist_url = "" 9 | self.bio = "" 10 | self.profile_picture_url = "" 11 | self.location = "" 12 | self.concerts = [] 13 | self.links = [] 14 | self.album_ids = [] 15 | 16 | # getting information from api 17 | response = requests.get( 18 | url="https://bandcamp.com/api/mobile/25/band_details?band_id=" + str(artist_id), 19 | ) 20 | result = response.json() 21 | self.artist_title = result['name'] 22 | self.artist_id = result['id'] 23 | self.artist_url = result['bandcamp_url'] 24 | self.bio = result['bio'] 25 | self.profile_picture_url = "https://f4.bcbits.com/img/" + str(result["bio_image_id"]).zfill(10) + "_0.jpg" 26 | self.location = result['location'] 27 | 28 | for show in result["shows"]: 29 | current_show = { 30 | "location": show["loc"], 31 | "venue": show["venue"], 32 | "date": show["date"], 33 | "url": show["uri"], 34 | "unix_time": show["utc_date"] 35 | } 36 | 37 | self.concerts.append(current_show) 38 | 39 | for link in result["sites"]: 40 | self.links.append(link["url"]) 41 | 42 | for album in result["discography"]: 43 | self.album_ids.append(album["item_id"]) 44 | -------------------------------------------------------------------------------- /bandcamp_api/bandcampjson.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | import demjson3 4 | 5 | class BandcampJSON: 6 | def __init__(self, body, debugging: bool = False): 7 | self.body = body 8 | self.json_data = [] 9 | 10 | if debugging: 11 | logging.basicConfig(level=logging.DEBUG) 12 | 13 | def generate(self): 14 | """Grabbing needed data from the page""" 15 | self.get_pagedata() 16 | self.get_js() 17 | return self.json_data 18 | 19 | def get_pagedata(self): 20 | logging.debug(" Grab pagedata JSON..") 21 | pagedata = self.body.find('div', {'id': 'pagedata'})['data-blob'] 22 | self.json_data.append(pagedata) 23 | 24 | def get_js(self): 25 | """Get