Package: bandcampsync
BandcampSyncBandcampSync is a Python module and command line script (also packed in
a Docker container) which synchronises media purchased on a Bandcamp
(http://bandcamp.com/) account with a local directory.You may use this to download media you have purchased from Bandcamp to a
local media server, such as Plex or Jellyfin.Most media items purchased on Bandcamp have high quality download options
available and BandcampSync defaults toflac.When called,bandcampsyncwill:Authenticate to bandcamp.com as you using your exported session cookiesScan your local media directory for existing downloaded itemsIndex a list of all of your purchased items in your Bandcamp collectionDownload the archive of missing items not downloaded already from your collectionUnzip the archive and move the contents to the local media directoryThe media directory will have the following format:/media/
/media/Artist Name
/media/Artist Name/Album Name
/media/Artist Name/Album Name/bandcamp_item_id.txt
/media/Artist Name/Album Name/cover.jpg
/media/Artist Name/Album Name/Track Name.flacThe directory format ofartist_name/item_titleis not editable.bandcamp_item_id.txtis a special file created in each item directory and
it contains the Bandcamp item ID as an integer. This file is used by BandcampSync
to track which media items have already been downloaded. You can rename the
artist or album directories, but do not delete thebandcamp_item_id.txtfile
or the media item will be redownloaded the next timebandcampsyncis run.Thebandcamp_item_id.txtfile method of tracking what items are synchronised
also means you can also use media managers such as Lidarr to rename artist,
album and track names automatically without issues.Installationbandcampsyncis pure Python and only has a dependancy on therequestsandbeautifulsoup4libraries. You can installbandcampsyncvia pip:$pipinstallbandcampsyncAny modern version of Python3 will be compatible.Alternatively, there's a batteries included Docker image available if you prefer.DockerThe Docker image contains thebandcampsyncPython module as well as a helper
script that runs thebandcampsyncon a timer. Configuration variables are also
moved to environment variablesYou can pull and run the image with the following commands:# Pull image$dockerpullghcr.io/meeb/bandcampsync:latest# Start the container using your user ID and group ID$dockerrun\-d\--namebandcampsync\-eTZ=Europe/London\-ePUID=1000\-ePGID=1000\-eRUN_DAILY_AT=3\-v/some/directory/bandcampsync-config:/config\-v/some/directory/bandcampsync-media:/downloads\ghcr.io/meeb/bandcampsync:latestOr an example Docker Compose entry:version:'3.7'services:bandcampsync:image:ghcr.io/meeb/bandcampsync:latestcontainer_name:bandcampsyncrestart:unless-stoppedvolumes:-/some/directory/bandcampsync-config:/config-/some/directory/bandcampsync-media:/downloadsenvironment:-TZ=Europe/London-PUID=1000-PGID=1000-RUN_DAILY_AT=3In the above example you would save your cookies data into a file calledcookies.txtand save it at/some/directory/bandcampsync-config/cookies.txt.
BandcampSync will look for this location when it starts up.TheRUN_DAILY_ATenvironment variable is the hour thebandcampsyncscript
will run at. In this example, 3am local time. After running the container will
sleep until the following 3am. It will run daily. There is also a randomised
delay added to the hour to not dogpile bandcamp.com with requests on the hour
so the script won't run exactly on the hour.RUN_DAILY_ATshould be a number between 0 and 23 (specifying an hour).PUIDandPGIDare the user and group IDs to attempt run the download as.
This sets the UID and GID of the files that are downloaded.TEMP_DIRvariable can be set to a directory in the container. If set the
directory is used as the temporary download location.ConfigurationBandcampSync requires minimial configuration. First, it requires your session
cookies from an authenticated Bandcamp account. The easiest way to get this is
to go tohttps://bandcamp.com/in your browser and log in with your account.Next, open the developer tools in your browser (F12 button on most browsers, or
select "developer tools" from the options menu).Reload the index page and find the index page request in your network requests
tab of your browser. Go to the "Request Headers" section then select and copy
the string after theCookieheader. The string should look something like this:client_id=00B1F3C8EB48E181A185CCD041E40C0E8F; session=1%0893C88%570EE405455%%8DEC37B5BC393983DB983DD%%BDFD46C3B8A0%%580DA466D5CD; identity=1%HhehuehUFEUiuebn%%2ADB72300DAE573%BEEF389A1B526EA35AC38019FA0A6F%11B4BD5FBC18B83F720; js_logged_in=1; logout=%7B%22username%22%3A%22someuser%22%7D; download_encoding=401; BACKENDID3=some-sever-nameSave this string to a file calledcookies.txt.You need to save your session ID from cookies manually because Bandcamp has
a captcha on the login form so BandcampSync can't log in with your username
and password for you.IMPORTANT NOTE: Keep thecookies.txtfile safe! Anyone with access to this file
can log into your Bandcamp account, impersonate you, potentially make purchases
and generally have total access to your Bandcamp account!CLI usageOnce you have the Pythonbandcampsyncmodule installed you can call it with thebandcampsynccommand:$bandcampsync--cookiescookies.txt--directory/path/to/musicor in shorthand:$bandcampsync-ccookies.txt-d/path/to/musicYou can also use-tor--temp-dirto set the temporary download directory used. See-hor--helpfor the full list of command line options.FormatsBy default, BandcampSync will download your music in theflacformat. You can specify
another format with the--formatargument. Common Bandcamp download formats are:NameDescriptionmp3-v0Variable bitrate MP3. Small file sizes. OK quality.mp3-320High quality MP3. Medium file sizes. Good quality.flacLosses audio. Large file sizes. Original Quality.aac-hiApple variable bitrate format. Small file sizes. OK quality.aiff-losslessUncompressed audio format. Biggest file size. Original quality.vorbisOpen source lossy format. Small file sizes. OK quality.alacApple lossless format. Large file sizes. Original quality.wavUncompressed audio format. Biggest file size. Original quality.You can also use-ior--ignoreto bypass artists that have data issues that
your OS can not handle.$bandcampsync--cookiescookies.txt--directory/path/to/music--ignore"badband"ContributingAll properly formatted and sensible pull requests, issues and comments are welcome.