彻底移除小爱音箱相关代码和文档引用
- 删除 setup_xiaomi.py(小米账号登录脚本) - 清理 CLAUDE.md 和 README.md 中的小爱/MiService 残留引用 - TTS 已完全本地化,无需任何小米服务
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
| `push_latest_order.py` | 单次获取最新订单并推送 |
|
||||
| `fetch_orders.py` | 复用 Cookie 获取订单数据(命令行) |
|
||||
| `fengxiang_scraper.py` | 首次登录获取 Cookie(Playwright 半自动) |
|
||||
| `setup_xiaomi.py` | 小米账号登录(已弃用,TTS 改为本地) |
|
||||
| `cookies.json` | 丰享平台登录 Cookie(自动生成) |
|
||||
|
||||
## 运行环境
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user