Giter Site home page Giter Site logo

mooc-dl's Introduction

mooc-dl

本程序提供**大学 MOOC 课件的下载,方便离线观看与复习,但本程序及其所得内容不可用于商业用途

Important

本程序已停止维护,如果你想要继续使用,请自行 fork 本项目并修改相关代码

Usage

在运行之前请确保安装 Python3.6 及以上版本,并安装依赖

pip install -r requirements.txt

之后在 config.json 中对一些参数进行配置就可以使用啦(登录只支持爱课程账号,因为其他的做起来太复杂,如果嫌注册太麻烦,直接使用这里放的共享账号就好)

Note

目前**大学 MOOC 已经会验证账号是否参加课程,因此请一定确保替换共享账号为自己的账号,并且确保自己的账号已经参加了课程

{
  "username": "<icourse_user_name>",      // 你的爱课程账号
  "password": "<icourse_password>",       // 你的爱课程账号密码
  "resolution": 0,                        // 清晰度等级,可选 0,1,2 清晰度递减
  "root": "",                             // 下载目标根目录
  "num_thread": 16,                       // 下载线程数
  "overwrite": false,                     // 是否强制覆盖已有文件
  "file_path_template": "{base_dir}{sep}{cnt_1} {chapter_name}{sep}{cnt_2} {lesson_name}{sep}{cnt_3} {unit_name}",
                                          // 文件存储路径模板,可据此自定义文件存储路径
  "range": {                              // 设置开始章节和结束章节
    "start": [0, 0, 0],
    "end": [999, 999, 999]
  },
  "file_types": [1, 3, 4],                // 下载文件类型,可选 1,3,4,分别代表视频、PDF、附件,默认全部下载
  "use_ffmpeg": false                     // 是否使用 FFmpeg 进行合并,需自行安装 FFmpeg
}

下载时,只需要以网址作为参数传入即可

python mooc-dl.py "https://www.icourse163.org/course/ZJU-93001?tid=1003997005"

此外还支持通过参数来覆盖配置,如

python mooc-dl.py "https://www.icourse163.org/course/ZJU-93001?tid=1003997005" --range="1.2~5.4" --file-types="1, 3" --use-ffmpeg --overwrite

Tips

关于文件路径

默认的文件路径是分级的,如果你不喜欢这样的效果,完全可以修改模板进行自定义,比如类似 course-crawler 那种分类式,你只需要将模版设置成这样即可

{
   "file_path_template": "{base_dir}{sep}{type}{sep}{cnt_3} {unit_name}"
}

进度条的问题

暂时进度条体验非常不佳,但不影响下载功能

关于维护

由于 Nyakku 已经很少使用**大学 MOOC 了,因此本程序不会积极维护,如果只是遇到小错误的话会尝试修复,但如果**大学 MOOC 发生大的 API 变动,本项目会停止维护……(应该快了) 已停止维护

License

本 Repo 采用 GPL-3.0 协议开源,请遵守该开源协议使用本项目,本项目源程序及所得内容均不可用于商业用途

mooc-dl's People

Contributors

arcticlampyrid avatar dependabot-preview[bot] avatar dependabot[bot] avatar frzmtrsprt avatar siguremo avatar zpcc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mooc-dl's Issues

🐛 下载失败

调用方式

python mooc-dl.py http://www.icourse163.org/learn/kaopei-1461594163?tid=1462381444#/learn/announce

环境信息

  • OS: windows10
  • Python: Python 3.8.5

问题简述

下载MOOC视频

使用默认账号:

Traceback (most recent call last):
  File "mooc-dl.py", line 216, in <module>
    term_id, course_name = get_summary(url)
  File "mooc-dl.py", line 65, in get_summary
    term_id = re.search(r'termId : "(\d+)"', res).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

修改config.json为自己的账号密码(账号密码无误):

密码错误!
Traceback (most recent call last):
  File "mooc-dl.py", line 216, in <module>
    term_id, course_name = get_summary(url)
  File "mooc-dl.py", line 65, in get_summary
    term_id = re.search(r'termId : "(\d+)"', res).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

🐛 下载课程出现错误代码

调用方式

环境信息

  • OS: Windows 10 1909 64Bit
  • Python: Python 3.9.1
  • Others: 其它信息

问题简述

预期行为

额外信息

是否愿意为此贡献代码

🐛 無法下載 出現 TypeError: 'NoneType'

调用方式

python mooc-dl.py "https://www.icourse163.org/course/NJUE-1458311167"

环境信息

  • OS: windows 10
  • Python: Python 3.10.9

问题简述

Python大数据分析 - 南京财经大学
1458311167
Traceback (most recent call last):
File "Z:\mooc-dl-master\mooc-dl.py", line 318, in
url, file_path, params = parse_resource(resource, token)
File "Z:\mooc-dl-master\mooc-dl.py", line 199, in parse_resource
pdf_url = res.json()["results"]["learnInfo"]["textOrigUrl"]
TypeError: 'NoneType' object is not subscriptable

额外信息

是否愿意为此贡献代码

枯了,还是 variable 'ext' referenced before assignment

Foair/course-crawler#37 (comment)

$ python mooc-dl.py  https://www.icourse163.org/course/0701TJU046-1003168003
线性代数学习指导 - 同济大学
1003168003
Traceback (most recent call last):
  File "mooc-dl.py", line 219, in <module>
    resource_list = get_resource(term_id, token)
  File "mooc-dl.py", line 160, in get_resource
    file_path += ext
UnboundLocalError: local variable 'ext' referenced before assignment

🐛 课程权限已到期

调用方式

python mooc-dl.py https://www.icourse163.org/course/BUCT-1002990004?tid=1470662444

环境信息

  • OS: Windows 10
  • Python: Python 3.9.6

问题简述

控制台报错:[ERROR] 无法获取课件信息!原因:「课程权限已到期,请重新购买」,疑似该课程已关闭。
调试程序后发现在mooc-dl.py文件中的get_courseinfo()函数返回值为:{'status': {'code': 403, 'message': '课程权限已到期,请重新购买'}, 'results': None, 'extraInfo': None}。

测试了多个课程链接,都有这样的报错。

预期行为

额外信息

是否愿意为此贡献代码

🐛 PDF下载失败, 内容为XML

调用方式

py3 mooc-dl.py https://www.icourse163.org/course/CSU-1206894807

环境信息

  • OS: ArchLinux
  • Python: 3.9.5
  • Others: 校园网

问题简述

下载的PDF, 其中一些的内容为:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>AccessDenied</Code>
  <Message>error_expires_timeout</Message>
  <Resource>%2Fedu-lesson-pdfsrc%2F87738B322EFBC1702D16411A66CBB130-1574991673443</Resource>
  <RequestId>77b97717-bce8-4924-b8b3-8d73df430074</RequestId>
</Error>

预期行为

PDF可以正常阅读

额外信息

去网页上查看, 发现下载出错的PDF可以正常阅读

今天重新下载一遍, 发现有问题的PDF集合不是相同的

出错的PDF集合从列表中间开始, 一直到末尾

是否愿意为此贡献代码

🐛 一直try again

环境信息

  • OS: win10
  • Python: 3.8 (conda)

问题简述

下载视频,前几章很顺利,但后边就开始没速度,然后就是一直
[warn] request timeout, trying again...
猜测可能是被api限速了?
换了一次网络,好了一小会,然后又没速度了,接着还是warn

🐛 下载时出现「FileNotFoundError」

调用方式

python mooc-dl.py https://www.icourse163.org/course/SWJTU-1207477804

环境信息

  • OS: Windows 11
  • Python: 3.8.10

问题简述

心理咨询理论和技术 - 西南交通大学
1207477804
Traceback (most recent call last):
  File "D:\XMIND\MoocDownload\mooc-dl\utils\crawler.py", line 26, in download_bin
    with open(tmp_path, "wb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '心理咨询理论和技术 - 西南交通大学\\11 团体心理工作技术\\11.1 团体咨询技术:保护干预 11.2 团体咨询技术:激励干预 11.2.1 激励干预1 11.2.2 激励干预2 11.3 团体过程分析 11.3.1 团体过程分析概述 11.3.2 团体过程分析模型 11.4 组员的行为 11.4.1 识别难处理的组员 11.4.2 特罗泽的分类:阻抗行为、操控行为、帮助行为 11.4.3 特罗泽的分类:情绪性行为、小团体行为\\11.1.1 团体咨询技术:保护干预_zh.srt.t'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "mooc-dl.py", line 311, in <module>
    url, file_path, params = parse_resource(resource, token)
  File "mooc-dl.py", line 184, in parse_resource
    spider.download_bin(srt_url, srt_path)
  File "D:\XMIND\MoocDownload\mooc-dl\utils\crawler.py", line 35, in download_bin
    os.remove(tmp_path)
FileNotFoundError: [WinError 3] The system cannot find the path specified: '心理咨询理论和技术 - 西南交通大学\\11 团体心理工作技术\\11.1 团体咨询技术:保护干预 11.2 团体咨询技术:激励干预 11.2.1 激励干预1 11.2.2 激励干预2 11.3 团体过程分析 11.3.1 团体过程分析概述 11.3.2 团体过程分析模型 11.4 组员的行为 11.4.1 识别难处理的组员 11.4.2 特罗泽的分类:阻抗行为、
操控行为、帮助行为 11.4.3 特罗泽的分类:情绪性行为、小团体行为\\11.1.1 团体咨询技术:保护干预_zh.srt.t'

预期行为

额外信息

是否愿意为此贡献代码

调用时出现相关json解析出错

调用方式

python mooc-dl.py https://www.icourse163.org/course/ZJU-93001?tid=1003997005

环境信息

  • OS: win10
  • Python: Python 3.7

问题简述

在调用相关命令时,出现

数据结构 - 浙江大学
93001
Traceback (most recent call last):
  File "E:\project\mooc-dl\mooc-dl.py", line 227, in <module>
    resource_list = get_resource(term_id, token, file_types=CONFIG["file_types"])
  File "E:\project\mooc-dl\mooc-dl.py", line 139, in get_resource
    course_info = get_courseinfo(term_id, token)
  File "E:\project\mooc-dl\mooc-dl.py", line 56, in get_courseinfo
    print('res响应结果:{},data:{}'.format(res.josn(),data))
AttributeError: 'Response' object has no attribute 'josn'

无法解析相关的一个返回结果

看到断点续传最近不希望提供

我在研究代码,不过最后还是没有想出来自己的解决方法

后来想到一个简单的, 记住下载的最后一个 数字 X:

然后下一次下载的时候:

在line 249里,直接X+1 for i, resource in enumerate(resource_list[X+1:]):

相当于一个断点续传。

🐛 使用其他路径保存不会下载视频

调用方式

$ python3 mooc-dl.py https://www.icourse163.org/course/PAEU-1003647009\?tid\=1450354443

环境信息

  • OS: ArchLinux
  • Python: 3.8.6
  • Others: 其它信息

问题简述

使用其他路径, 下载的文件夹里没有视频

https://www.icourse163.org/course/PAEU-1003647009?tid=1450354443

预期行为

额外信息

在配置文件里使用过 /tmp/..., /run/media/... 位置, 但都没有视频. 使用默认配置会正常.

是否愿意为此贡献代码

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.