No project description provided
Project description
chaoxing-downloader
学习通课程视频下载工具,支持浏览器登录、课程/章节/视频三级浏览
依赖:Python 3.11+、httpx、beautifulsoup4、playwright(Chromium)
Python 库使用,见 Python API 文档。
安装
pip install chaoxing-downloader
登录
chaoxing-downloader init
会弹出浏览器,手动登录超星后自动:
- 采集
.chaoxing.comcookie 并写入config.toml - 写入课程列表和课程入口参数到
.chaoxing-cache.json
可选参数:
--config config.toml 配置文件写入路径(默认 config.toml)
--user-data-dir .chaoxing-browser 浏览器数据目录
--timeout 300 等待登录超时秒数
--course-delay 2.0 预热课程入口时,每门课程进入前等待秒数
配置文件
默认读当前目录的 config.toml,由 init 自动生成,通常不需要手动编辑:
[session]
cookie = "UID=...; vc3=...; uf=...; p_auth_token=..."
referer = "https://mooc1.chaoxing.com/"
[entry]
base_url = "https://i.chaoxing.com/base"
[download]
output_dir = "downloads"
[cache]
path = ".chaoxing-cache.json"
用法
# 列出所有课程
chaoxing-downloader list-courses
# 列出某门课的章节
chaoxing-downloader list-chapters --course course-54600bb5
# 列出某章节的视频
chaoxing-downloader list-videos --chapter chapter-0434a4f3
# 下载视频
chaoxing-downloader download-video --video video-6d0d9300
# 清理缓存
chaoxing-downloader clear-cache
课程/章节/视频查询和下载命令支持 --delay <seconds>,用于降低请求频率:
chaoxing-downloader list-courses --delay 1.5
chaoxing-downloader list-chapters --course course-54600bb5 --delay 1.5
chaoxing-downloader list-videos --chapter chapter-0434a4f3 --delay 1.5
chaoxing-downloader download-video --video video-6d0d9300 --delay 1.5
所有命令支持 --config <path> 指定配置文件。
Python 示例
仓库内提供了一个最小示例脚本,会自动判断是否已初始化、列出第一个课程/章节/视频并下载:
python examples/download_first_video.py
缓存
解析结果缓存在 .chaoxing-cache.json(路径由 [cache].path 控制),包括课程/章节/视频的 key、URL、object_id 和下载地址。
课程入口参数
部分课程进入章节时需要从课程入口页拿到 enc、t 等参数。init 会在登录后自动预热课程并缓存最终课程入口 URL,正常情况下不需要手动处理。
常见问题
Playwright 未安装
.\.venv\Scripts\python -m pip install playwright
.\.venv\Scripts\python -m playwright install chromium
中文乱码
$env:PYTHONIOENCODING='utf-8'
未安装为命令
$env:PYTHONPATH='.\src'
python -m chaoxing_downloader list-courses
许可证
本项目基于 MIT License 开源。
免责声明
本项目仅用于用户本人已授权课程的视频离线学习和技术研究,不提供任何课程资源,不支持免登录、绕过权限、绕过付费、破解加密或 DRM。
使用者应遵守所在学校、平台服务协议和相关法律法规。通过本工具下载的内容仅限个人学习使用,不得传播、转售、公开分享或用于任何商业用途。因使用本项目产生的账号风险、版权纠纷或其他后果由使用者自行承担。
本项目不会上传、收集或共享用户 Cookie、课程信息和下载内容。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chaoxing_downloader-0.1.2.tar.gz.
File metadata
- Download URL: chaoxing_downloader-0.1.2.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06a752159ade5445137da2637a2ff2b1f266fbaa8a476f8333946d05328bf4c7
|
|
| MD5 |
06ae5b6dcf58885c6d810a107bba56a3
|
|
| BLAKE2b-256 |
595ff7f1398d1410c50c2a7886d008f0de00fac9033c5ff086673e9362d6125d
|
File details
Details for the file chaoxing_downloader-0.1.2-py3-none-any.whl.
File metadata
- Download URL: chaoxing_downloader-0.1.2-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f11a9a8922e4815090ff5e4b88e13266179bd55b28b0333cbb20413e4912fe66
|
|
| MD5 |
312fd0fedcb6f48e8e226161073cfa2e
|
|
| BLAKE2b-256 |
9087c0934f9207376c8e21abadbcf48796a164ecd6b9f60ce4d65d6f8ba11d4e
|