calliope.bandcamp

Access data from Bandcamp.

This module wraps a local fork of the bandcamp_api library. Additionally, some information is scraped from the Bandcamp website using BeautifulSoup4.

Authentication

All the APIs used by this module can be accessed without authentication.

Caching

FIXME: some requests are cached now.

HTTP requests are not cached. At time of writing, api.bandcamp.com requests send the HTTP header Cache-Control: no-cache, no-store.

Web pages that are scraped for data will get cached, see function documentation for more details.

Package Contents

Classes

BandcampContext

Context for accessing Bandcamp API.

Functions

export_band(context, band_url[, expand_albums, ...])

Export all albums for a Bandcamp artist or label.

export_album(context[, album_url, album_id, cache_expiry])

Export all tracks in an album

collection(bandcamp[, count])

Export all albums in Bandcamp collection.

wishlist(bandcamp[, count])

Export all albums in Bandcamp wishlist.

exception calliope.bandcamp.ScrapeError

Bases: RuntimeError

Unspecified run-time error.

Initialize self. See help(type(self)) for accurate signature.

class calliope.bandcamp.BandcampContext(config, user=None)

Context for accessing Bandcamp API.

Parameters
get_fan_id()
calliope.bandcamp.export_band(context, band_url, expand_albums=False, cache_expiry=None)

Export all albums for a Bandcamp artist or label.

This uses web scraping as I am not aware of an API that provides the info. It may provide incomplete data and may stop working based on changes to the Bandcamp site.

The remote page is cached, and by default is only refreshed if older than 1 week. Use cache_expiry to set a different expiry interval.

Parameters
Return type

calliope.playlist.Playlist

calliope.bandcamp.export_album(context, album_url=None, album_id=None, cache_expiry=None)

Export all tracks in an album

The remote page is cached, and by default is never refreshed. Use cache_expiry to set an expiry interval if needed.

Parameters

context (BandcampContext) –

Return type

calliope.playlist.Playlist

calliope.bandcamp.collection(bandcamp, count=1000)

Export all albums in Bandcamp collection.

Parameters

bandcamp (BandcampContext) –

Return type

calliope.playlist.Playlist

calliope.bandcamp.wishlist(bandcamp, count=1000)

Export all albums in Bandcamp wishlist.

Parameters

bandcamp (BandcampContext) –

Return type

calliope.playlist.Playlist