Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WSL2 users running SAU from WSL bash want to use their desktop Chrome (already logged into the platform) for scan-QR login instead of letting Playwright launch a fresh bundled Chromium. The mechanism is the Chrome DevTools Protocol (CDP) — Playwright
connect_over_cdp()attaches to an already-running browser instead of spawning one.Doublin / Kuaishou already had
--cdp-url(wired in earlier work). The other three Playwright-based platforms — xiaohongshu, tencent, youtube — were missing it, leaving WSL users on those platforms no choice but to either:cdp_urlthemselves.Bilibili uses biliup CLI (subprocess), so
--cdp-urlis not applicable there.Fix
uploader/xiaohongshu_uploader/main.py— addcdp_urltoxiaohongshu_setupandxiaohongshu_cookie_gen. Insidecookie_gen, whencdp_urlis set, useplaywright.chromium.connect_over_cdp()instead oflaunch(), reuse existing context if present. Guardbrowser.close()withshould_close_browserflag (CDP browser must NOT be closed).uploader/tencent_uploader/main.py— same pattern fortencent_setup,tencent_cookie_gen,get_tencent_cookie.uploader/youtube_uploader/main.py— same pattern foryoutube_setup,youtube_cookie_gen.sau_cli.py— addcdp_urlparameter tologin_xiaohongshu_account,login_tencent_account,login_youtube_account. Add--cdp-urlargparse to xiaohongshu, tencent, youtube login parsers (mirroring douyin/kuaishou). Wirecdp_url=args.cdp_urlat dispatch sites.docs/WSL-USER-GUIDE.md— new file covering the full WSL2 / Linux-server workflow:--headedis the default for douyin (anti-bot detection).batmust be ASCII (UTF-8 echo trap in cmd GBK)--user-data-dirpreservationWhy
--cdp-urlmatters for WSLA typical WSL2 user setup:
127.0.0.1(WSL has its own loopback)172.19.224.1(vEthernet (WSL) bridge IP)So WSL users run a Python TCP proxy on Windows that forwards
0.0.0.0:9222→[::1]:9222(Chrome's actual bind address on Windows after Chrome 111+ removed--remote-debugging-address). Then SAU attaches via--cdp-url http://172.19.224.1:9222.Without this fix, SAU would launch a new headless Chromium (no UI, can't scan QR) or fail outright if no browser is available.
Usage
# Desktop Chrome already running on Windows with --remote-debugging-port=9222 sau xiaohongshu login --account myaccount --headed --cdp-url http://172.19.224.1:9222 sau tencent login --account myaccount --headed --cdp-url http://172.19.224.1:9222 sau youtube login --account myaccount --headed --cdp-url http://172.19.224.1:9222Testing
--cdp-urlcorrectly:Affected files
Related
SAU_BROWSER_CHANNELoverride) — the first half of the WSL story.