diff --git a/README.md b/README.md index 4eca053..f581d92 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Download free and $0 minimum name-your-price albums and tracks from Bandcamp (including ones that are sent to email), and tag them with data from the Bandcamp page. Also able to download items in your collection, if login cookies are -supplied using the `--cookies` argument. +supplied using the `--cookies` or `--identity` argument. ## Installation @@ -11,13 +11,19 @@ Install with pip pip install free-bandcamp-downloader ``` +## Note on passing cookies + +Only one cookie is needed to login, which has the name "identity". You can pass this cookie to `bcdl-free` using the +`--cookies` argument which you must supply a path to a Netscape cookies.txt formatted file, or using the `--identity` +argument which you must supply the value of your "identity" cookie. + ## Usage ``` Usage: bcdl-free (-a | -l )[--force][--no-unzip][-d | --dir ][-e | --email ] [-z | --zipcode ][-c | --country ][-f | --format ] - [--cookies ][--debug] + [--cookies ][--identity ][--debug] bcdl-free setdefault [-d | --dir ][-e | --email ][-z | --zipcode ] [-c | --country ][-f | --format ] bcdl-free defaults @@ -40,6 +46,7 @@ Options: -e --email Set email (set to 'auto' to automatically download from a disposable email) -f --format Set format --cookies Path to cookies.txt file so albums in your collection can be downloaded + --identity Value of identity cookie so albums in your collection can be downloaded --debug Set loglevel to debug Formats: - FLAC diff --git a/free_bandcamp_downloader/__main__.py b/free_bandcamp_downloader/__main__.py index b5e9152..b28d47c 100644 --- a/free_bandcamp_downloader/__main__.py +++ b/free_bandcamp_downloader/__main__.py @@ -2,7 +2,7 @@ Usage: bcdl-free (-a | -l )[--force][--no-unzip][-d | --dir ][-e | --email ] [-z | --zipcode ][-c | --country ][-f | --format ] - [--cookies ][--debug] + [--cookies ][--identity ][--debug] bcdl-free setdefault [-d | --dir ][-e | --email ][-z | --zipcode ] [-c | --country ][-f | --format ] bcdl-free defaults @@ -25,6 +25,7 @@ Options: -e --email Set email (set to 'auto' to automatically download from a disposable email) -f --format Set format --cookies Path to cookies.txt file so albums in your collection can be downloaded + --identity Value of identity cookie so albums in your collection can be downloaded --debug Set loglevel to debug Formats: - FLAC @@ -110,6 +111,7 @@ class BCFreeDownloader: download_history_file: str, unzip: bool = True, cookies_file: Optional[str] = None, + identity: Optional[str] = None, ): self.options = options self.config_dir = config_dir @@ -121,7 +123,7 @@ class BCFreeDownloader: self.session = None self._init_email() self._init_downloaded() - self._init_session(cookies_file) + self._init_session(cookies_file, identity) def _init_email(self): if not self.options.email or self.options.email == "auto": @@ -134,12 +136,14 @@ class BCFreeDownloader: for line in f: self.downloaded.add(line.strip()) - def _init_session(self, cookies_file: Optional[str]): + def _init_session(self, cookies_file: Optional[str], identity: Optional[str]): self.session = requests.Session() if cookies_file: cj = MozillaCookieJar(cookies_file) cj.load() self.session.cookies = cj + if identity: + self.session.cookies.set("identity", identity) def _download_file( self, @@ -355,7 +359,7 @@ class BCFreeDownloader: else: raise BCFreeDownloadError( f"{url} is not free. If you have purchased this album, " - "use the --cookies flag to pass your login cookies." + "use the --cookies flag or --identity flag to pass your login cookie." ) def download_label(self, url: str, force: bool = False): @@ -501,6 +505,7 @@ def main(): config.get("download_history_file"), not arguments["--no-unzip"], arguments["--cookies"], + arguments["--identity"], ) if arguments["-a"]: downloader.download_album(arguments["-a"], arguments["--force"]) diff --git a/pyproject.toml b/pyproject.toml index 9eb15d8..0aee86a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "free-bandcamp-downloader" -version = "0.3.2" +version = "0.3.3" description = "Download free and name-your-price albums from Bandcamp in lossless quality" authors = ["7x11x13 "] license = "MIT"