Skip to main content

Extract BandCamp .zip album folders to their appropriate place

Project description

Band Camp Album Extractor

This python script extracts all of the songs for a bandcamp album download.

Install

(preferred) from pip

pip install bandcamp_extract

From github repo

To install this package simply run

pip install .

in the root of this package

Setup

After installation the extractor's binary is called bcextr.

Breaking change (0.2.0): bcextr is now a command group. What used to be bcextr <zip> is now bcextr extract <zip>.

bcextr extract works standalone with no setup. The bcextr api commands pull albums directly from your Bandcamp collection, which requires a one-time login first.

Bandcamp has no username/password API, so this reuses the same session cookie your browser already has after you log in on bandcamp.com.

1. Get your Bandcamp username

This is the name in the URL of your own collection page: https://bandcamp.com/<username>. You can find it in the account menu on bandcamp.com, or from the URL after clicking "Collection".

2. Get your identity cookie

  1. Log in to bandcamp.com in your browser.
  2. Open developer tools (F12, or Cmd+Opt+I on macOS).
  3. Go to the Application tab in Chrome/Edge (Storage tab in Firefox), then Cookieshttps://bandcamp.com in the left sidebar.
  4. Find the row named identity and copy its Value column. It's a long opaque string — copy the whole thing.

This cookie is a live login credential for your account: don't share it, paste it into chat tools, or commit it anywhere. bcextr only stores it locally in ~/.config/bcextr/session.json (readable only by you).

3. Log in with bcextr

bcextr api login

You'll be prompted for your Bandcamp username and the cookie value from the steps above.

If your cookie later expires, just re-run bcextr api login with a fresh value.

Shell completion (optional)

bcextr is built on Click, which provides tab-completion for subcommands (extract, api, mv, etc.) and file/directory paths (including for --pattern, which completes like a regular folder path). Add the line for your shell to its startup file, then restart your shell (or source the file):

bash (~/.bashrc):

eval "$(_BCEXTR_COMPLETE=bash_source bcextr)"

zsh (~/.zshrc):

eval "$(_BCEXTR_COMPLETE=zsh_source bcextr)"

fish: generate the completion file once (no eval-on-startup needed):

_BCEXTR_COMPLETE=fish_source bcextr > ~/.config/fish/completions/bcextr.fish

Usage

bcextr extract

Extract a zip you already downloaded:

bcextr extract ~/Downloads/album.zip --pattern ~/Music/{artist}/{album}/{title}

Default pattern if not provided is: ./{artist}/{album}/{title}

bcextr api list / bcextr api choose

List your collection:

bcextr api list

Pick albums and extract them straight to your library:

bcextr api choose --pattern ~/Music/{albumartist}/{album}/{title} --format flac

This opens an fzf multi-select over your collection, downloads each chosen album in the requested format, and runs it through the same extract/rename logic as bcextr extract.

--format accepts one of mp3-320, mp3-v0, flac, aac-hi, vorbis, alac, wav, aiff-lossless. If omitted, you'll get a format picker (applied to the whole batch) instead.

This relies on Bandcamp's unofficial, undocumented collection API and may break if Bandcamp changes it.

bcextr mv / bcextr cp

Reorganize an existing folder of music (searched recursively, however deep the files are nested) into a pattern-based structure. mv moves the files (the originals are gone); cp copies them, leaving the originals in place:

bcextr mv ~/Music --pattern ~/New_Music/{albumartist}/{album}/{title}
bcextr cp ~/Music --pattern ~/New_Music/{albumartist}/{album}/{title}

Pattern substitution

The pattern substitution will substitute any parameter it gets in tinytag The file extension will also be added to the end of the pattern when moving the song to it's destination

tag.album         # album as string
tag.albumartist   # album artist as string
tag.artist        # artist name as string
tag.audio_offset  # number of bytes before audio data begins
tag.bitrate       # bitrate in kBits/s
tag.comment       # file comment as string
tag.composer      # composer as string 
tag.disc          # disc number
tag.disc_total    # the total number of discs
tag.duration      # duration of the song in seconds
tag.filesize      # file size in bytes
tag.genre         # genre as string
tag.samplerate    # samples per second
tag.title         # title of the song
tag.track         # track number as string
tag.track_total   # total number of tracks as string
tag.year          # year or data as string

It is important to note that any files that are not music (in the zip, or in the source folder for bcextr mv/bcextr cp) are not moved or copied to the destination folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bandcamp_extract-0.4.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bandcamp_extract-0.4.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file bandcamp_extract-0.4.0.tar.gz.

File metadata

  • Download URL: bandcamp_extract-0.4.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bandcamp_extract-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e3bcf73a26cdfa391415994b781966e177fdd555fe90b54fac2fbd20627e6c4a
MD5 d429086f2b7aab5c3077de9eacdf74c7
BLAKE2b-256 2a131ffa69aa9b37753e143362aee45f99031b1c3c5ee3094331c48360d7dd21

See more details on using hashes here.

Provenance

The following attestation bundles were made for bandcamp_extract-0.4.0.tar.gz:

Publisher: release.yml on JonMontgo/bandcamp_extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bandcamp_extract-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bandcamp_extract-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8e2b6df540101c816c1f65a085c144b9503899991ceda20d5b0b0d204d5e9bc
MD5 8b5f56842c5a043f7864aa66c2579971
BLAKE2b-256 64f92aaff78b871217e3d7e98f3e0a152e1d0cf24dab5e2e6321128e3f292fe9

See more details on using hashes here.

Provenance

The following attestation bundles were made for bandcamp_extract-0.4.0-py3-none-any.whl:

Publisher: release.yml on JonMontgo/bandcamp_extract

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page