feat: add pure Python COS upload and improve login detection
- feat(cos): add cos_upload.py for direct file upload without browser
- implements COS V1 signature algorithm with temporary credentials
- upload_image() pipeline: get_upload_info → sign → PUT to COS
- feat(api): auto-load cookies from file when cookies arg is omitted
- both Hunyuan3DAPI and Hunyuan3DAPIComplete now fall back to
~/.config/hunyuan3dweb/cookies.txt automatically
- fix(login): strengthen login-state detection using both URL and DOM
- checks "login" not in page.url AND no login button on page
- docs: update README / README_CN with COS upload examples
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -56,9 +56,12 @@ def main():
|
||||
page.goto("https://3d.hunyuan.tencent.com/", timeout=60000)
|
||||
page.wait_for_timeout(2000)
|
||||
|
||||
# 检查是否已经是登录状态(没有登录按钮说明已登录)
|
||||
# 检查是否已经是登录状态:URL 不含 login 且页面上没有登录按钮
|
||||
is_login_page = "login" in page.url
|
||||
login_btn = page.locator("button").filter(has_text="登录").first
|
||||
if login_btn.count() == 0:
|
||||
has_login_btn = login_btn.count() > 0
|
||||
|
||||
if not is_login_page and not has_login_btn:
|
||||
print("检测到已有登录状态,无需重新登录。")
|
||||
print(f"当前页面: {page.url}")
|
||||
_extract_and_save_cookies(context)
|
||||
@@ -70,6 +73,10 @@ def main():
|
||||
login_btn.click()
|
||||
page.locator("text=邮箱").wait_for(state="visible", timeout=10000)
|
||||
|
||||
# 定位元素
|
||||
email_input = page.locator('input[placeholder="请输入邮箱地址"]')
|
||||
code_input = page.locator('input[type="number"][placeholder="请输入邮箱验证码"]')
|
||||
|
||||
# 切换到邮箱登录
|
||||
email_tab = page.locator("text=邮箱").first
|
||||
if email_tab.count() > 0:
|
||||
@@ -78,10 +85,6 @@ def main():
|
||||
else:
|
||||
print("未找到邮箱登录选项")
|
||||
return
|
||||
|
||||
# 定位元素
|
||||
email_input = page.locator('input[placeholder="请输入邮箱地址"]')
|
||||
code_input = page.locator('input[type="number"][placeholder="请输入邮箱验证码"]')
|
||||
send_code_btn = page.locator("a.hyc-email-login__send-code")
|
||||
login_submit_btn = page.locator("button.hyc-email-login__btn")
|
||||
checkbox = page.locator(".t-checkbox__former")
|
||||
|
||||
Reference in New Issue
Block a user