mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-01-03 01:15:57 +10:00
Fix: Make SingleFile use SINGLEFILE_CHROME_ARGS with fallback to CHROME_ARGS
This fix resolves issue #1445 where SingleFile was not respecting Chrome user data directory and other Chrome launch options that work for other Chrome-based extractors (PDF, Screenshot, etc.). Changes: - Added SINGLEFILE_CHROME_ARGS config option in config.json with x-fallback to CHROME_ARGS - Updated SingleFile extractor to read and pass Chrome arguments via --browser-args parameter - Updated docstring to document the new environment variable This ensures SingleFile respects the same Chrome configuration (user data directory, cookies, etc.) as other Chrome-based extractors. Fixes #1445 Co-authored-by: Nick Sweeting <pirate@users.noreply.github.com>
This commit is contained in:
@@ -52,6 +52,13 @@
|
||||
"x-fallback": "CHECK_SSL_VALIDITY",
|
||||
"description": "Whether to verify SSL certificates"
|
||||
},
|
||||
"SINGLEFILE_CHROME_ARGS": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"default": [],
|
||||
"x-fallback": "CHROME_ARGS",
|
||||
"description": "Chrome command-line arguments for SingleFile"
|
||||
},
|
||||
"SINGLEFILE_ARGS": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
|
||||
@@ -14,6 +14,7 @@ Environment variables:
|
||||
SINGLEFILE_USER_AGENT: User agent string (x-fallback: USER_AGENT)
|
||||
SINGLEFILE_COOKIES_FILE: Path to cookies file (x-fallback: COOKIES_FILE)
|
||||
SINGLEFILE_CHECK_SSL_VALIDITY: Whether to verify SSL certs (x-fallback: CHECK_SSL_VALIDITY)
|
||||
SINGLEFILE_CHROME_ARGS: Chrome command-line arguments (x-fallback: CHROME_ARGS)
|
||||
SINGLEFILE_ARGS: Default SingleFile arguments (JSON array)
|
||||
SINGLEFILE_ARGS_EXTRA: Extra arguments to append (JSON array)
|
||||
"""
|
||||
@@ -134,6 +135,7 @@ def save_singlefile(url: str, binary: str) -> tuple[bool, str | None, str]:
|
||||
cookies_file = get_env('SINGLEFILE_COOKIES_FILE') or get_env('COOKIES_FILE', '')
|
||||
singlefile_args = get_env_array('SINGLEFILE_ARGS', [])
|
||||
singlefile_args_extra = get_env_array('SINGLEFILE_ARGS_EXTRA', [])
|
||||
chrome_args = get_env_array('SINGLEFILE_CHROME_ARGS') or get_env_array('CHROME_ARGS', [])
|
||||
chrome = get_env('SINGLEFILE_CHROME_BINARY') or get_env('CHROME_BINARY', '')
|
||||
|
||||
cmd = [binary, *singlefile_args]
|
||||
@@ -149,6 +151,11 @@ def save_singlefile(url: str, binary: str) -> tuple[bool, str | None, str]:
|
||||
elif chrome:
|
||||
cmd.extend(['--browser-executable-path', chrome])
|
||||
|
||||
# Pass Chrome arguments (includes user-data-dir and other launch options)
|
||||
if chrome_args:
|
||||
# SingleFile expects --browser-args as a JSON array string
|
||||
cmd.extend(['--browser-args', json.dumps(chrome_args)])
|
||||
|
||||
# SSL handling
|
||||
if not check_ssl:
|
||||
cmd.append('--browser-ignore-insecure-certs')
|
||||
|
||||
Reference in New Issue
Block a user