From cc963694a3bbc8df963d9d4084862ba8ef930474 Mon Sep 17 00:00:00 2001 From: DerekEXS Date: Tue, 16 Jun 2026 20:12:39 +0800 Subject: [PATCH] fix(export_douyin_cookie): read USERNAME from os.environ in embedded python The shell passed USERNAME as an environment variable to the embedded python heredoc (USERNAME=$USERNAME python3 ...), but the python block referenced USERNAME as if it were already a local variable. The result was NameError on every run, so the export script could never produce a cookies/_.json file. Fix: read the env var explicitly with os.environ.get('USERNAME', '') at the top of the embedded block, then use the local USERNAME as before. --- export_douyin_cookie.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/export_douyin_cookie.sh b/export_douyin_cookie.sh index 57afd9b..6285794 100644 --- a/export_douyin_cookie.sh +++ b/export_douyin_cookie.sh @@ -52,6 +52,9 @@ import os import uuid import sys +# Shell 把 USERNAME 作为环境变量传过来, Python 需要显式取 +USERNAME = os.environ.get('USERNAME', '') + DEBUG_PORT = 9222 if USERNAME: COOKIE_FILE = f"cookies/douyin_{USERNAME}.json"