From ab6a2bb7ead58b15113b2390f3e6f0e89affaae1 Mon Sep 17 00:00:00 2001 From: houhuan Date: Tue, 12 May 2026 17:18:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=BB=E5=BA=95=E7=A7=BB=E9=99=A4=E5=B0=8F?= =?UTF-8?q?=E7=88=B1=E9=9F=B3=E7=AE=B1=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=92=8C=E6=96=87=E6=A1=A3=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 setup_xiaomi.py(小米账号登录脚本) - 清理 CLAUDE.md 和 README.md 中的小爱/MiService 残留引用 - TTS 已完全本地化,无需任何小米服务 --- CLAUDE.md | 6 +--- README.md | 1 - setup_xiaomi.py | 83 ------------------------------------------------- 3 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 setup_xiaomi.py diff --git a/CLAUDE.md b/CLAUDE.md index 94f2933..4a19b1e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,9 +12,7 @@ | `push_latest_order.py` | 单次获取最新订单并推送企业微信 | | `fetch_orders.py` | 复用 Cookie 获取订单数据(命令行) | | `fengxiang_scraper.py` | 首次登录获取 Cookie(Playwright 半自动) | -| `setup_xiaomi.py` | 小米账号登录获取 serviceToken(Playwright) | | `cookies.json` | 丰享平台的登录 Cookie | -| `xiaomi_config.json` | 小米账号和音箱配置 | | `order_data.json` | 订单数据样例 | ## 已逆向的 API @@ -65,7 +63,7 @@ ## 消息格式 - 企业微信: `【丰享丰食】订单收款成功,收款24.00元` -- 小爱音箱: `收到新订单,收款24元`(口语化,整数不带小数点) +- 本地TTS: 同上文案语音播报 ## 已安装的依赖 @@ -77,6 +75,4 @@ playwright install chromium ## 注意事项 - 丰享登录有**腾讯验证码 TCaptcha**,无法纯接口绕过,必须用 Playwright 浏览器登录 -- 小米 passToken 会过期,过期后需重新运行 `setup_xiaomi.py` 登录 - Windows 终端输出中文会乱码,但实际发送的内容是正确的 UTF-8 -- MiService 的 `miaccount.py` 第 68 行已修改:`self.password.encode()` 加了 None 检查(passToken 登录时 password 为 None) diff --git a/README.md b/README.md index c8bf873..016b139 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ | `push_latest_order.py` | 单次获取最新订单并推送 | | `fetch_orders.py` | 复用 Cookie 获取订单数据(命令行) | | `fengxiang_scraper.py` | 首次登录获取 Cookie(Playwright 半自动) | -| `setup_xiaomi.py` | 小米账号登录(已弃用,TTS 改为本地) | | `cookies.json` | 丰享平台登录 Cookie(自动生成) | ## 运行环境 diff --git a/setup_xiaomi.py b/setup_xiaomi.py deleted file mode 100644 index 2d38a6f..0000000 --- a/setup_xiaomi.py +++ /dev/null @@ -1,83 +0,0 @@ -""" -小米账号登录 - 通过浏览器获取 serviceToken -浏览器打开后请手动登录,脚本会自动检测登录成功 -""" - -import json -import time -from playwright.sync_api import sync_playwright - -XIAOI_CONFIG = "xiaomi_config.json" - - -def login_and_get_tokens(): - print("启动浏览器,请登录小米账号...") - with sync_playwright() as p: - browser = p.chromium.launch(headless=False, args=["--start-maximized"]) - context = browser.new_context(no_viewport=True) - page = context.new_page() - - page.goto("https://account.xiaomi.com/pass/serviceLogin?sid=micoapi&_json=true&callback=https%3A%2F%2Fapi2.mina.mi.com%2Fsts") - page.wait_for_load_state("networkidle") - - print("请在浏览器中完成登录(输入手机号、密码、验证码)") - print("等待登录完成(最长5分钟)...") - - # 等待页面离开登录页(说明登录成功) - try: - page.wait_for_url(lambda url: "account.xiaomi.com/pass" not in url, timeout=300_000) - print("检测到登录成功!") - except Exception: - print("登录超时或失败") - browser.close() - return None - - time.sleep(3) - - # 获取 cookies - cookies = context.cookies() - cookie_dict = {c["name"]: c["value"] for c in cookies} - - service_token = cookie_dict.get("serviceToken", "") - user_id = cookie_dict.get("userId", "") - - print(f"获取到 {len(cookies)} 个 cookies") - print(f" userId: {user_id}") - print(f" serviceToken: {'有' if service_token else '无'}") - - # 通过浏览器调用 device_list API - print("\n获取设备列表...") - result = page.evaluate(""" - async () => { - const resp = await fetch('https://api2.mina.mi.com/admin/v2/device_list?master=0&requestId=app_ios_' + Math.random().toString(36).substr(2, 30)); - return await resp.json(); - } - """) - - devices = [] - if result.get("code") == 0: - devices = result.get("data", []) - print(f"找到 {len(devices)} 个设备:") - for d in devices: - print(f" 名称: {d.get('name')} | 型号: {d.get('hardware')} | DID: {d.get('deviceID')}") - else: - print(f"获取设备失败: {result}") - - # 保存配置 - config = { - "userId": user_id, - "serviceToken": service_token, - "devices": devices, - "allCookies": cookie_dict, - } - - with open(XIAOI_CONFIG, "w", encoding="utf-8") as f: - json.dump(config, f, ensure_ascii=False, indent=2) - - print(f"\n配置已保存到 {XIAOI_CONFIG}") - browser.close() - return config - - -if __name__ == "__main__": - login_and_get_tokens()