Install
openclaw skills install @gandli/cttc-auto-learn烟草网络学院 (mooc.ctt.cn) 自动学习脚本,支持刷学时、刷专题、刷课程、刷任务四种模式。 用户说"帮我刷学时"即可自动完成登录、播放视频、累计学时全流程。 触发词:烟草、网络学院、mooc、cttc、自动学习、学时。
openclaw skills install @gandli/cttc-auto-learn用户只需安装此 SKILL,说"帮我刷学时"即可。Agent 自动完成环境搭建、登录、学习。
| 模式 | 命令 | 说明 |
|---|---|---|
| 刷学时 | uv run python main.py --mode hours | 播放视频累计学时(默认) |
| 刷专题 | uv run python main.py --mode topics | 完成专题课程 |
| 刷课程 | uv run python main.py --mode courses | 完成所有未完成课程 |
| 刷任务 | uv run python main.py --mode tasks | 完成指定任务 |
触发词对应模式:
--mode hours--mode topics--mode courses--mode tasks# 检查项目是否存在
if [ ! -d ~/Desktop/cttc-auto-learn ]; then
git clone https://github.com/gandli/cttc-auto-learn.git ~/Desktop/cttc-auto-learn
fi
cd ~/Desktop/cttc-auto-learn
cd ~/Desktop/cttc-auto-learn
uv sync
# 杀掉残留 Chrome 进程(注意:不要误杀其他 Chrome)
taskkill //F //IM chrome.exe 2>/dev/null || true
# 清除 Python 缓存
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
检查凭证文件是否存在且有效:
ls output/auth-state.json 2>/dev/null
如果不存在或已过期,需要用户扫码登录:
cd ~/Desktop/cttc-auto-learn
uv run python main.py
登录流程特性:
framenavigated),扫码后立即检测成功二维码图片位置:
output/qrcode-app.png — APP 扫码output/qrcode-wechat.png — 微信扫码Agent 操作步骤:
tail -20 ~/Desktop/cttc-auto-learn/logs/cttc.log | grep "QR_PATHS"
output/auth-state.json如果已存在,跳到 Step 5。
cd ~/Desktop/cttc-auto-learn
uv run python main.py
脚本会自动:
output/auth-state.json)脚本运行后,Agent 必须主动监控状态并定期向用户汇报进展。
# 检查 Python 进程
tasklist 2>/dev/null | grep -i python || echo "脚本未运行"
# 或检查状态文件是否存在
ls ~/Desktop/cttc-auto-learn/output/status.json 2>/dev/null && echo "脚本已启动" || echo "脚本未运行"
状态文件 output/status.json 每 30 秒自动更新,Agent 可直接读取:
cat ~/Desktop/cttc-auto-learn/output/status.json
状态字段说明:
| 字段 | 类型 | 说明 |
|---|---|---|
status | string | playing / completed / error |
current_video | string | 当前播放的课程名称 |
video_progress | float | DOM 进度百分比 (0-100) |
api_completed_rate | int | API 返回的完成率 |
study_hours_current | float | 当前学时 |
study_hours_target | float | 目标学时 |
courses_completed | int | 已完成课程数 |
courses_pending | int | 待学课程数 |
courses_total | int | 总课程数 |
errors_count | int | 累计错误次数 |
stall_recoveries | int | 停滞恢复次数 |
uptime_seconds | int | 运行时长(秒) |
last_update | string | 最后更新时间 |
在另一个终端运行实时监控(有进度条和颜色):
cd ~/Desktop/cttc-auto-learn
uv run python scripts/monitor.py
tail -50 ~/Desktop/cttc-auto-learn/logs/cttc.log
Agent 应定期(每 5-10 分钟或用户询问时)读取状态并向用户汇报:
📊 当前状态
- 状态: playing
- 视频: 全链路数智化转型 (48.1%)
- 学时: 28.1/50.0h (56.2%)
- 课程: 0 完成 / 76 待学
- 运行: 25 分钟
- 错误: 0 次
关键事件必须立即通知用户:
status 变为 completed 或新视频开始)study_hours_current 变化)errors_count 增加)study_hours_current >= study_hours_target)在 main.py 中可调整:
| 参数 | 默认值 | 说明 |
|---|---|---|
target_hours | 50 | 目标学时(小时) |
headless | False | 无头模式(不显示浏览器窗口) |
| 问题 | 原因 | 解决 |
|---|---|---|
40909 多开限制 | localStorage 残留旧会话 | 脚本已自动处理(启动时清除) |
40904 错误 | studyTime 不正确 | 脚本已自动修正为增量值 |
| 浏览器崩溃 | GPU 进程异常 | 脚本已加 --disable-gpu 参数 |
| 学时不增长 | 服务器异步结算 | 持续运行,隔天检查 |
| 二维码过期 | 超过 2 分钟未扫码 | 脚本会自动刷新二维码 |
d8cg8gVakEq9Agup