feat(alipay): add Alipay life account video uploader
- New uploader/alipay_uploader module: QR-code cookie login, upload page flow, title/desc/tags fill, thumbnail, collection and publish - sau_cli: add 'alipay login/check/upload-video' subcommands - examples: get_alipay_cookie.py and test_alipay_upload.py - utils/log.py: register alipay logger - utils/login_qrcode.py: robust QR decode on non-ASCII Windows paths (numpy imdecode with cv2.imread fallback)
This commit is contained in:
@@ -5,6 +5,7 @@ from pathlib import Path
|
||||
import sys
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import segno
|
||||
|
||||
|
||||
@@ -35,13 +36,16 @@ def remove_qrcode_file(qrcode_path: Path | None) -> bool:
|
||||
|
||||
|
||||
def decode_qrcode_from_path(qrcode_path: Path) -> str | None:
|
||||
# Windows 下 cv2.imread 不支持中文路径, 改用 np.fromfile + imdecode
|
||||
import numpy as np
|
||||
|
||||
# Windows 下 cv2.imread 对中文路径不稳定,优先走 numpy+imdecode
|
||||
image = None
|
||||
try:
|
||||
image = cv2.imdecode(np.fromfile(str(qrcode_path), dtype=np.uint8), cv2.IMREAD_COLOR)
|
||||
data = np.fromfile(str(qrcode_path), dtype=np.uint8)
|
||||
if data.size > 0:
|
||||
image = cv2.imdecode(data, cv2.IMREAD_COLOR)
|
||||
except Exception:
|
||||
return None
|
||||
image = None
|
||||
if image is None:
|
||||
image = cv2.imread(str(qrcode_path))
|
||||
if image is None:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user