Skip to main content

No project description provided

Project description

chaoxing-downloader

学习通课程视频下载工具,支持浏览器登录、课程/章节/视频三级浏览

依赖:Python 3.11+、httpx、beautifulsoup4、DrissionPage,并需要本机已安装 Chrome 或 Edge 等 Chromium 系浏览器。

Python 库使用,见 Python API 文档

安装

pip install chaoxing-downloader

登录

chaoxing-downloader init

会弹出浏览器,手动登录超星后自动:

  • 采集 .chaoxing.com cookie 并写入 config.toml
  • 写入课程列表和课程入口参数到 .chaoxing-cache.json

可选参数:

--config config.toml            配置文件写入路径(默认 config.toml)
--user-data-dir .chaoxing-browser   浏览器数据目录
--timeout 300                   等待登录超时秒数
--course-delay 2.0              预热课程入口时,每门课程进入前等待秒数
--browser-port 9223             DrissionPage 本地调试端口

配置文件

默认读当前目录的 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"

[browser]
port = 9223

用法

# 列出所有课程
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 和下载地址。

课程入口参数

部分课程进入章节时需要从课程入口页拿到 enct 等参数。init 会在登录后自动预热课程并缓存最终课程入口 URL,正常情况下不需要手动处理。

常见问题

浏览器未启动或 DrissionPage 未安装

.\.venv\Scripts\python -m pip install DrissionPage

DrissionPage 会复用本机 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

chaoxing_downloader-0.1.3.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chaoxing_downloader-0.1.3-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file chaoxing_downloader-0.1.3.tar.gz.

File metadata

  • Download URL: chaoxing_downloader-0.1.3.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for chaoxing_downloader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8d8c4e7b9e9b20b84ea51f75e4d0b9ad51c9f1013aaa0259981e3f14fc073dfc
MD5 05f5ef3b8868fabbab1ec0f39cb46ac3
BLAKE2b-256 aeda35f476b3a6f14de37ca689b0c24ed7383d518aa3936b315f69dc055a76f1

See more details on using hashes here.

File details

Details for the file chaoxing_downloader-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for chaoxing_downloader-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ead05bee1528574a667acdc0907073714418fda8b2df8d73604870c5914745ee
MD5 31a89bf223bedd7f4196e93bcd7f4c9b
BLAKE2b-256 76173fd022d5796deddeaf79836ad2d13b86ef8728d02b375022437d97001027

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page