bandcampsync


Namebandcampsync JSON
Version 0.3.9 PyPI version JSON
download
home_pagehttps://github.com/meeb/bandcampsync
SummaryA Python module and script to synchronise media purchased on bandcamp.com with a local directory.
upload_time2023-11-19 03:24:26
maintainer
docs_urlNone
authorhttps://github.com/meeb
requires_python
licenseBSD
keywords bandcampsync bandcamp media sync
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BandcampSync

BandcampSync 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 to `flac`.

When called, `bandcampsync` will:

1. Authenticate to bandcamp.com as you using your exported session cookies
2. Scan your local media directory for existing downloaded items
3. Index a list of all of your purchased items in your Bandcamp collection
4. Download the archive of missing items not downloaded already from your collection
5. Unzip the archive and move the contents to the local media directory

The 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.flac
```

The directory format of `artist_name`/`item_title` is not editable.

`bandcamp_item_id.txt` is 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 the `bandcamp_item_id.txt` file
or the media item will be redownloaded the next time `bandcampsync` is run.

The `bandcamp_item_id.txt` file 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.


## Installation

`bandcampsync` is pure Python and only has a dependancy on the `requests` and
`beautifulsoup4` libraries. You can install `bandcampsync` via pip:

```bash
$ pip install bandcampsync
```

Any modern version of Python3 will be compatible.

Alternatively, there's a batteries included Docker image available if you prefer.


## Docker

The Docker image contains the `bandcampsync` Python module as well as a helper
script that runs the `bandcampsync` on a timer. Configuration variables are also
moved to environment variables

You can pull and run the image with the following commands:

```bash
# Pull image
$ docker pull ghcr.io/meeb/bandcampsync:latest
# Start the container using your user ID and group ID
$ docker run \
  -d \
  --name bandcampsync \
  -e TZ=Europe/London \
  -e PUID=1000 \
  -e PGID=1000 \
  -e RUN_DAILY_AT=3 \
  -v /some/directory/bandcampsync-config:/config \
  -v /some/directory/bandcampsync-media:/downloads \
  ghcr.io/meeb/bandcampsync:latest

```

Or an example Docker Compose entry:

```bash
version: '3.7'
services:
  bandcampsync:
    image: ghcr.io/meeb/bandcampsync:latest
    container_name: bandcampsync
    restart: unless-stopped
    volumes:
      - /some/directory/bandcampsync-config:/config
      - /some/directory/bandcampsync-media:/downloads
    environment:
      - TZ=Europe/London
      - PUID=1000
      - PGID=1000
      - RUN_DAILY_AT=3
```

In the above example you would save your cookies data into a file called
`cookies.txt` and save it at `/some/directory/bandcampsync-config/cookies.txt`.
BandcampSync will look for this location when it starts up.

The `RUN_DAILY_AT` environment variable is the hour the `bandcampsync` script
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_AT` should be a number between 0 and 23 (specifying an hour).

`PUID` and `PGID` are the user and group IDs to attempt run the download as.
This sets the UID and GID of the files that are downloaded.

`TEMP_DIR` variable can be set to a directory in the container. If set the
directory is used as the temporary download location.


## Configuration

BandcampSync requires minimial configuration. First, it requires your session
cookies from an authenticated Bandcamp account. The easiest way to get this is
to go to https://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 the `Cookie` header. 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-name
```

Save this string to a file called `cookies.txt`.

![Getting your session cookues](https://github.com/meeb/bandcampsync/blob/main/docs/cookies.jpg?raw=true)

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 the `cookies.txt` file 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 usage

Once you have the Python `bandcampsync` module installed you can call it with the
`bandcampsync` command:

```bash
$ bandcampsync --cookies cookies.txt --directory /path/to/music
```

or in shorthand:

```bash
$ bandcampsync -c cookies.txt -d /path/to/music
```

You can also use `-t` or `--temp-dir` to set the temporary download directory used. See
`-h` or `--help` for the full list of command line options.

## Formats

By default, BandcampSync will download your music in the `flac` format. You can specify
another format with the `--format` argument. Common Bandcamp download formats are:

| Name            | Description                                                     |
| --------------- | --------------------------------------------------------------- |
| `mp3-v0`        | Variable bitrate MP3. Small file sizes. OK quality.             |
| `mp3-320`       | High quality MP3. Medium file sizes. Good quality.              |
| `flac`          | Losses audio. Large file sizes. Original Quality.               |
| `aac-hi`        | Apple variable bitrate format. Small file sizes. OK quality.    |
| `aiff-lossless` | Uncompressed audio format. Biggest file size. Original quality. |
| `vorbis`        | Open source lossy format. Small file sizes. OK quality.         |
| `alac`          | Apple lossless format. Large file sizes. Original quality.      |
| `wav`           | Uncompressed audio format. Biggest file size. Original quality. |

You can also use `-i` or `--ignore` to bypass artists that have data issues that
your OS can not handle.

```bash
$ bandcampsync --cookies cookies.txt --directory /path/to/music --ignore "badband"
```

# Contributing

All properly formatted and sensible pull requests, issues and comments are welcome.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/meeb/bandcampsync",
    "name": "bandcampsync",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "bandcampsync,bandcamp,media,sync",
    "author": "https://github.com/meeb",
    "author_email": "meeb@meeb.org",
    "download_url": "https://files.pythonhosted.org/packages/70/7b/7126d0d74c9a73e10efd8054b775a6eb95a51a84c0a4af247cfbedc10901/bandcampsync-0.3.9.tar.gz",
    "platform": null,
    "description": "# BandcampSync\n\nBandcampSync is a Python module and command line script (also packed in\na Docker container) which synchronises media purchased on a Bandcamp\n(http://bandcamp.com/) account with a local directory.\n\nYou may use this to download media you have purchased from Bandcamp to a\nlocal media server, such as Plex or Jellyfin.\n\nMost media items purchased on Bandcamp have high quality download options\navailable and BandcampSync defaults to `flac`.\n\nWhen called, `bandcampsync` will:\n\n1. Authenticate to bandcamp.com as you using your exported session cookies\n2. Scan your local media directory for existing downloaded items\n3. Index a list of all of your purchased items in your Bandcamp collection\n4. Download the archive of missing items not downloaded already from your collection\n5. Unzip the archive and move the contents to the local media directory\n\nThe media directory will have the following format:\n\n```\n/media/\n/media/Artist Name\n/media/Artist Name/Album Name\n/media/Artist Name/Album Name/bandcamp_item_id.txt\n/media/Artist Name/Album Name/cover.jpg\n/media/Artist Name/Album Name/Track Name.flac\n```\n\nThe directory format of `artist_name`/`item_title` is not editable.\n\n`bandcamp_item_id.txt` is a special file created in each item directory and\nit contains the Bandcamp item ID as an integer. This file is used by BandcampSync\nto track which media items have already been downloaded. You can rename the\nartist or album directories, but do not delete the `bandcamp_item_id.txt` file\nor the media item will be redownloaded the next time `bandcampsync` is run.\n\nThe `bandcamp_item_id.txt` file method of tracking what items are synchronised\nalso means you can also use media managers such as Lidarr to rename artist,\nalbum and track names automatically without issues.\n\n\n## Installation\n\n`bandcampsync` is pure Python and only has a dependancy on the `requests` and\n`beautifulsoup4` libraries. You can install `bandcampsync` via pip:\n\n```bash\n$ pip install bandcampsync\n```\n\nAny modern version of Python3 will be compatible.\n\nAlternatively, there's a batteries included Docker image available if you prefer.\n\n\n## Docker\n\nThe Docker image contains the `bandcampsync` Python module as well as a helper\nscript that runs the `bandcampsync` on a timer. Configuration variables are also\nmoved to environment variables\n\nYou can pull and run the image with the following commands:\n\n```bash\n# Pull image\n$ docker pull ghcr.io/meeb/bandcampsync:latest\n# Start the container using your user ID and group ID\n$ docker run \\\n  -d \\\n  --name bandcampsync \\\n  -e TZ=Europe/London \\\n  -e PUID=1000 \\\n  -e PGID=1000 \\\n  -e RUN_DAILY_AT=3 \\\n  -v /some/directory/bandcampsync-config:/config \\\n  -v /some/directory/bandcampsync-media:/downloads \\\n  ghcr.io/meeb/bandcampsync:latest\n\n```\n\nOr an example Docker Compose entry:\n\n```bash\nversion: '3.7'\nservices:\n  bandcampsync:\n    image: ghcr.io/meeb/bandcampsync:latest\n    container_name: bandcampsync\n    restart: unless-stopped\n    volumes:\n      - /some/directory/bandcampsync-config:/config\n      - /some/directory/bandcampsync-media:/downloads\n    environment:\n      - TZ=Europe/London\n      - PUID=1000\n      - PGID=1000\n      - RUN_DAILY_AT=3\n```\n\nIn the above example you would save your cookies data into a file called\n`cookies.txt` and save it at `/some/directory/bandcampsync-config/cookies.txt`.\nBandcampSync will look for this location when it starts up.\n\nThe `RUN_DAILY_AT` environment variable is the hour the `bandcampsync` script\nwill run at. In this example, 3am local time. After running the container will\nsleep until the following 3am. It will run daily. There is also a randomised\ndelay added to the hour to not dogpile bandcamp.com with requests on the hour \nso the script won't run exactly on the hour.\n\n`RUN_DAILY_AT` should be a number between 0 and 23 (specifying an hour).\n\n`PUID` and `PGID` are the user and group IDs to attempt run the download as.\nThis sets the UID and GID of the files that are downloaded.\n\n`TEMP_DIR` variable can be set to a directory in the container. If set the\ndirectory is used as the temporary download location.\n\n\n## Configuration\n\nBandcampSync requires minimial configuration. First, it requires your session\ncookies from an authenticated Bandcamp account. The easiest way to get this is\nto go to https://bandcamp.com/ in your browser and log in with your account.\n\nNext, open the developer tools in your browser (F12 button on most browsers, or\nselect \"developer tools\" from the options menu).\n\nReload the index page and find the index page request in your network requests\ntab of your browser. Go to the \"Request Headers\" section then select and copy\nthe string after the `Cookie` header. The string should look something like this:\n\n```\nclient_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-name\n```\n\nSave this string to a file called `cookies.txt`.\n\n![Getting your session cookues](https://github.com/meeb/bandcampsync/blob/main/docs/cookies.jpg?raw=true)\n\nYou need to save your session ID from cookies manually because Bandcamp has\na captcha on the login form so BandcampSync can't log in with your username\nand password for you.\n\nIMPORTANT NOTE: Keep the `cookies.txt` file safe! Anyone with access to this file\ncan log into your Bandcamp account, impersonate you, potentially make purchases\nand generally have total access to your Bandcamp account!\n\n\n## CLI usage\n\nOnce you have the Python `bandcampsync` module installed you can call it with the\n`bandcampsync` command:\n\n```bash\n$ bandcampsync --cookies cookies.txt --directory /path/to/music\n```\n\nor in shorthand:\n\n```bash\n$ bandcampsync -c cookies.txt -d /path/to/music\n```\n\nYou can also use `-t` or `--temp-dir` to set the temporary download directory used. See\n`-h` or `--help` for the full list of command line options.\n\n## Formats\n\nBy default, BandcampSync will download your music in the `flac` format. You can specify\nanother format with the `--format` argument. Common Bandcamp download formats are:\n\n| Name            | Description                                                     |\n| --------------- | --------------------------------------------------------------- |\n| `mp3-v0`        | Variable bitrate MP3. Small file sizes. OK quality.             |\n| `mp3-320`       | High quality MP3. Medium file sizes. Good quality.              |\n| `flac`          | Losses audio. Large file sizes. Original Quality.               |\n| `aac-hi`        | Apple variable bitrate format. Small file sizes. OK quality.    |\n| `aiff-lossless` | Uncompressed audio format. Biggest file size. Original quality. |\n| `vorbis`        | Open source lossy format. Small file sizes. OK quality.         |\n| `alac`          | Apple lossless format. Large file sizes. Original quality.      |\n| `wav`           | Uncompressed audio format. Biggest file size. Original quality. |\n\nYou can also use `-i` or `--ignore` to bypass artists that have data issues that\nyour OS can not handle.\n\n```bash\n$ bandcampsync --cookies cookies.txt --directory /path/to/music --ignore \"badband\"\n```\n\n# Contributing\n\nAll properly formatted and sensible pull requests, issues and comments are welcome.\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A Python module and script to synchronise media purchased on bandcamp.com with a local directory.",
    "version": "0.3.9",
    "project_urls": {
        "Homepage": "https://github.com/meeb/bandcampsync"
    },
    "split_keywords": [
        "bandcampsync",
        "bandcamp",
        "media",
        "sync"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "707b7126d0d74c9a73e10efd8054b775a6eb95a51a84c0a4af247cfbedc10901",
                "md5": "b4bb19902d7550fbb19fa1d3bc30adaa",
                "sha256": "14a64c6033bac238df347f178cfb5f00138717162d10341845c28ad1a850f198"
            },
            "downloads": -1,
            "filename": "bandcampsync-0.3.9.tar.gz",
            "has_sig": false,
            "md5_digest": "b4bb19902d7550fbb19fa1d3bc30adaa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17254,
            "upload_time": "2023-11-19T03:24:26",
            "upload_time_iso_8601": "2023-11-19T03:24:26.965396Z",
            "url": "https://files.pythonhosted.org/packages/70/7b/7126d0d74c9a73e10efd8054b775a6eb95a51a84c0a4af247cfbedc10901/bandcampsync-0.3.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-19 03:24:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "meeb",
    "github_project": "bandcampsync",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "bandcampsync"
}
        
Elapsed time: 0.15678s