chore: 去掉脚本 BOM;登录校验复用统一客户端;login.bat 不再强依赖环境变量
This commit is contained in:
1 parent
92bd4e1b59
commit
73462d94a0
4 files changed
+19
-34
No files matched your search
+14
-23
@@ -70,29 +70,20 @@ def login_with_browser(login_url: str) -> dict[str, str] | None:
|
|||||||
return cookies
|
return cookies
|
||||||
|
|
||||||
|
|
||||||
def verify(cookies: dict[str, str]) -> bool:
|
def verify(cfg, cookies: dict[str, str]) -> bool:
|
||||||
"""本地先验一次,避免把坏 Cookie 推上去。"""
|
"""本地先验一次,避免把坏 Cookie 推上去。"""
|
||||||
import requests as _rq
|
from fengxiang.client import FengxiangClient, FengxiangError
|
||||||
resp = _rq.post(
|
|
||||||
"https://fs.szfx.com/saasmerchant/pcweb/order/quickpayorder/list",
|
client = FengxiangClient(cfg)
|
||||||
json={"shopId": "20434543575189", "page": 1, "pageSize": 1},
|
client.set_cookies(cookies)
|
||||||
headers={
|
try:
|
||||||
"Content-Type": "application/json",
|
orders = client.list_orders(page_size=1)
|
||||||
"Referer": MMS_BASE,
|
except FengxiangError as exc:
|
||||||
"Origin": "https://fs.szfx.com",
|
print(f" Cookie 校验失败:{exc}", file=sys.stderr)
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
|
return False
|
||||||
},
|
latest = orders[0].get("orderId") if orders else None
|
||||||
cookies=cookies,
|
print(f" Cookie 校验通过(最新订单 {latest})")
|
||||||
timeout=20,
|
return True
|
||||||
)
|
|
||||||
data = resp.json()
|
|
||||||
if data.get("errno") == 0:
|
|
||||||
orders = (data.get("data") or {}).get("list") or []
|
|
||||||
latest = orders[0].get("orderId") if orders else None
|
|
||||||
print(f" Cookie 校验通过(最新订单 {latest})")
|
|
||||||
return True
|
|
||||||
print(f" Cookie 校验失败:errno={data.get('errno')} {data.get('errmsg')}", file=sys.stderr)
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def upload(server: str, token: str, cookies: dict[str, str]) -> bool:
|
def upload(server: str, token: str, cookies: dict[str, str]) -> bool:
|
||||||
@@ -122,7 +113,7 @@ def main() -> int:
|
|||||||
if not cookies:
|
if not cookies:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not verify(cookies):
|
if not verify(cfg, cookies):
|
||||||
print("Cookie 不可用,未保存。", file=sys.stderr)
|
print("Cookie 不可用,未保存。", file=sys.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
"""本地 TTS 语音播报(IndexTTS2),仅 Windows 本地模式使用。
|
"""本地 TTS 语音播报(IndexTTS2),仅 Windows 本地模式使用。
|
||||||
|
|
||||||
服务器/容器不会启用(无 torch、无声卡),由 fengxiang.tts.Speaker 在非 win32 平台直接跳过。
|
服务器/容器不会启用(无 torch、无声卡),由 fengxiang.tts.Speaker 在非 win32 平台直接跳过。
|
||||||
|
|
||||||
|
|||||||
@@ -20,20 +20,14 @@ if errorlevel 1 (
|
|||||||
"%PYTHON%" -m playwright install chromium
|
"%PYTHON%" -m playwright install chromium
|
||||||
)
|
)
|
||||||
|
|
||||||
:: 服务器地址与 token:优先用环境变量,也可直接改下面两行
|
:: 服务器地址:优先用环境变量,也可直接改这一行
|
||||||
if not defined FX_SERVER set "FX_SERVER=http://192.168.8.210:52100"
|
if not defined FX_SERVER set "FX_SERVER=http://192.168.8.210:52100"
|
||||||
if not defined FX_ADMIN_TOKEN (
|
:: 上传用的 token 自动从本地 config.yaml 的 admin.token 读取;也可用 FX_ADMIN_TOKEN 覆盖
|
||||||
echo [错误] 请先设置管理接口 token,例如:
|
|
||||||
echo set FX_ADMIN_TOKEN=你的token
|
|
||||||
echo token 与服务器 config.yaml 里 admin.token 一致
|
|
||||||
pause
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
echo [1/2] 打开浏览器登录丰享...
|
echo [1/2] 打开浏览器登录丰享...
|
||||||
echo.
|
echo.
|
||||||
"%PYTHON%" fengxiang_scraper.py --upload --server "%FX_SERVER%"
|
"%PYTHON%" fengxiang_scraper.py --upload --server "%FX_SERVER%"
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo [2/2] 完成。若提示上传失败,请检查服务器地址/token。
|
echo [2/2] 完成。若提示上传失败,请检查服务器地址 / config.yaml 里的 admin.token。
|
||||||
pause
|
pause
|
||||||
Reference in new issue
Block a user