feat: remove --cookie/--useragent, update README for token auth

- Remove --cookie and --useragent CLI parameters
- Update README: replace cookie/UA setup guide with --token
- Update favorites auth check message
- Bump version to 2.0.7

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ricter Zheng
2026-04-02 18:23:02 +08:00
parent 1131df0b94
commit b28dbc6d86
4 changed files with 8 additions and 42 deletions

View File

@@ -52,26 +52,11 @@ For a self-contained installation, use `pipx <https://github.com/pipxproject/pip
===== =====
Usage Usage
===== =====
**⚠IMPORTANT⚠**: To bypass Cloudflare, you should use ``--cookie`` and ``--useragent`` options to store your cookie and user-agent. **⚠IMPORTANT⚠**: Authentication is required. Get your API token from your account settings page and save it:
.. code-block:: bash .. code-block:: bash
doujinshi-dl --useragent "USER AGENT of YOUR BROWSER" doujinshi-dl --token "YOUR_API_TOKEN"
doujinshi-dl --cookie "YOUR COOKIE"
**NOTE:**
- The format of the cookie is ``"csrftoken=TOKEN; sessionid=ID; cf_clearance=CLOUDFLARE"``
- ``cf_clearance`` cookie and useragent must be set if you encounter "blocked by cloudflare captcha" error. Make sure you use the same IP and useragent as when you got it
| To get csrftoken and sessionid, first login to your account in a web browser, then:
| (Chrome) |ve| |ld| More tools |ld| Developer tools |ld| Application |ld| Storage |ld| Cookies |ld| your mirror URL
| (Firefox) |hv| |ld| Web Developer |ld| Web Developer Tools |ld| Storage |ld| Cookies |ld| your mirror URL
|
.. |hv| unicode:: U+2630 .. https://www.compart.com/en/unicode/U+2630
.. |ve| unicode:: U+22EE .. https://www.compart.com/en/unicode/U+22EE
.. |ld| unicode:: U+2014 .. https://www.compart.com/en/unicode/U+2014
*The default download folder will be the path where you run the command (%cd% or $PWD).* *The default download folder will be the path where you run the command (%cd% or $PWD).*
@@ -185,9 +170,7 @@ Other options:
folder when generated CBZ or PDF file folder when generated CBZ or PDF file
--regenerate regenerate the cbz or pdf file if exists --regenerate regenerate the cbz or pdf file if exists
--zip package into a single zip file --zip package into a single zip file
--cookie COOKIE set cookie to bypass Cloudflare captcha --token TOKEN set API token for authentication
--useragent, --user-agent USERAGENT
set useragent to bypass Cloudflare captcha
--language LANGUAGE set default language to parse doujinshis --language LANGUAGE set default language to parse doujinshis
--clean-language set DEFAULT as language to parse doujinshis --clean-language set DEFAULT as language to parse doujinshis
--save-download-history --save-download-history
@@ -197,7 +180,6 @@ Other options:
clean download history clean download history
--template VIEWER_TEMPLATE --template VIEWER_TEMPLATE
set viewer template set viewer template
--legacy use legacy searching method
====== ======
Mirror Mirror

View File

@@ -1,3 +1,3 @@
__version__ = '2.0.6' __version__ = '2.0.7'
__author__ = 'RicterZ' __author__ = 'RicterZ'
__email__ = 'ricterzheng@gmail.com' __email__ = 'ricterzheng@gmail.com'

View File

@@ -162,12 +162,8 @@ def cmd_parser():
parser.add_argument('--zip', action='store_true', help='Package into a single zip file') parser.add_argument('--zip', action='store_true', help='Package into a single zip file')
# site options # site options
parser.add_argument('--cookie', type=str, dest='cookie',
help='set cookie to bypass Cloudflare captcha')
parser.add_argument('--token', type=str, dest='token', parser.add_argument('--token', type=str, dest='token',
help='set API token for authentication (takes priority over cookie)') help='set API token for authentication')
parser.add_argument('--useragent', '--user-agent', type=str, dest='useragent',
help='set useragent to bypass Cloudflare captcha')
parser.add_argument('--language', type=str, dest='language', parser.add_argument('--language', type=str, dest='language',
help='set default language to parse doujinshis') help='set default language to parse doujinshis')
parser.add_argument('--clean-language', dest='clean_language', action='store_true', default=False, parser.add_argument('--clean-language', dest='clean_language', action='store_true', default=False,
@@ -217,30 +213,18 @@ def cmd_parser():
sys.exit(0) sys.exit(0)
# --- set config --- # --- set config ---
if args.cookie is not None:
logger.warning('--cookie is deprecated, please use --token instead.')
c.CONFIG['cookie'] = args.cookie.strip()
write_config()
logger.info('Cookie saved.')
if args.token is not None: if args.token is not None:
c.CONFIG['token'] = args.token.strip() c.CONFIG['token'] = args.token.strip()
write_config() write_config()
logger.info('Token saved.') logger.info('Token saved.')
if args.useragent is not None:
logger.warning('--useragent is deprecated, please use --token instead.')
c.CONFIG['useragent'] = args.useragent.strip()
write_config()
logger.info('User-Agent saved.')
if args.language is not None: if args.language is not None:
c.CONFIG['language'] = args.language c.CONFIG['language'] = args.language
write_config() write_config()
logger.info(f'Default language now set to "{args.language}"') logger.info(f'Default language now set to "{args.language}"')
# TODO: search without language # TODO: search without language
if any([args.cookie, args.token, args.useragent, args.language]): if any([args.token, args.language]):
sys.exit(0) sys.exit(0)
if args.proxy is not None: if args.proxy is not None:
@@ -271,7 +255,7 @@ def cmd_parser():
if args.favorites: if args.favorites:
if not c.CONFIG.get('cookie') and not c.CONFIG.get('token'): if not c.CONFIG.get('cookie') and not c.CONFIG.get('token'):
logger.warning('Authentication has not been set, please use `doujinshi-dl --token \'TOKEN\'` or `--cookie \'COOKIE\'` to set it.') logger.warning('Token has not been set, please use `doujinshi-dl --token \'TOKEN\'` to set it.')
sys.exit(1) sys.exit(1)
if args.file: if args.file:

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "doujinshi-dl" name = "doujinshi-dl"
version = "2.0.6" version = "2.0.7"
description = "doujinshi downloader" description = "doujinshi downloader"
authors = ["Ricter Z <ricterzheng@gmail.com>"] authors = ["Ricter Z <ricterzheng@gmail.com>"]
license = "MIT" license = "MIT"