Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
2021.7.18
Browse files Browse the repository at this point in the history
  • Loading branch information
yeefire committed Jul 18, 2021
1 parent 9f8105a commit 054eddc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,30 @@

本着环保、节能、减排的目的,开始了尝试对腾讯课堂网页版中自己购买了课程的视频回放进行下载。

# 更新记录

## 2021.7.18

- 更新后钉钉回放可以通过本脚本下载了
- 请重新pull拉取本项目,进入虚拟环境。重新执行`pip3 install -r requirements.txt`来完成本次更新。

1. 更新user-agent
2. 使用`requests[security]`,解决SSL错误。请重新执行`pip3 install -r requirements.txt`来进行更新。

使用方法:

* 先安装依赖模块 `pip3 install pycrypto m3u8 aiofiles requests_async`
* 命令行执行 `python3 tencent_class_m3u8.py 这节课的名称 这节课的M3U文件请求地址(网址或者本地路径都可以)`
1. 克隆本项目到某当前 `git clone https://github.com/yeefire/cloud-class-replay.git`
2. 进入项目目录 `cd cloud-class-replay`
3. 创建虚拟环境 `pyhton3 -m venv ./venv`
4. 激活虚拟环境 `source venv/bin/activate`
5. 先安装依赖模块 `pip3 install -r requirements.txt`
6. 命令行执行
- 下载腾讯课堂回放:`python3 tencent_class_m3u8.py 这节课的名称 这节课的M3U文件请求地址(网址或者本地路径都可以)`
- 下载钉钉回放:`python3 dingtalk_class_m3u8_standard.py 这节课的名称 这节课的M3U文件请求地址(网址或者本地路径都可以)`

7. 脚本会在运行的目录创建一个这节课名的文件夹,最终下载合成后的视频就在这个目录里。

* 钉钉有两个下载脚本,顺序下载和异步方式下载。建议使用`dingtalk_class_m3u8_standard.py`,如果你希望并发下载请尝试使用`dingtalk_class_m3u8_async.py`

例如: `python3 tencent_class_m3u8.py 【Python进阶】Python-上午 https://1dada217.vod2.myqcloud.com/fdadadada3kmdkfsxxxxxxxxxxxxxxxxx`

Expand Down
10 changes: 5 additions & 5 deletions dingtalk_class_m3u8_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import os, sys
import asyncio

class_video_name = sys.argv[1]
m3u8_file_uri = sys.argv[2]
# class_video_name = sys.argv[1]
class_video_name = "Teasync"
# m3u8_file_uri = sys.argv[2]
m3u8_file_uri = 'https://dtliving-sz.dingtalk.com/live_hp/50c76578-f922-48cd-a3e8-0c789a14248d_merge.m3u8?app_type=mac&auth_key=1627431132-0-0-3ffe8c22fb3aa0c7883db7a53a05de5d&cid=3f50c462bbd1b19733455dff4addb7e3&token=3fec44afc70cc00a65b4d378dc52a520OlunyFPNJ6IUJwA2HDEU8To5wezU_-DqtAB5r2rNRHqFi4Fc-ebSUSe8g0RPgMygY9wbEShiXmx728T0ikwfT7IT1yEoAqVGnBNJx12_ehg=&token2=ed619b628a7e774c93bdabef7bc053cerTCNQru0YJ49PlMzblg202aMXn1urxkDApmB_Xg2-1j_1k5PWJ2XEHnHg2mL-KVCoFkvCQ9GA8N3yzd5OhFePzop4g76YfaBe-kvKJqgkYU&version=5.1.40'
prefix_request_url = f'{m3u8_file_uri.rsplit("/", 1)[0]}/'

headers={
'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36 DingTalk(5.1.38-macOS-macOS-MAS-14284537) nw Channel/201200'
}
headers={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36 DingTalk(5.1.40-macOS-macOS-MAS-14354546) nw Channel/201200'}

async def download_m3u8_video(index: int, suffix_url: str):
if not os.path.exists(f'{class_video_name}/downloads/{index}.ts'):
Expand Down
3 changes: 2 additions & 1 deletion dingtalk_class_m3u8_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

class_video_name = sys.argv[1]
m3u8_file_uri = sys.argv[2]
prefix_request_url = f'{m3u8_file_uri.rsplit("/", 1)[0]}/'

prefix_request_url = f'{m3u8_file_uri.rsplit("/", 1)[0]}/'
headers={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36 DingTalk(5.1.40-macOS-macOS-MAS-14354546) nw Channel/201200'}

def download_m3u8_video(index: int, suffix_url: str):
if not os.path.exists(f'{class_video_name}/downloads/{index}.ts'):
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pycrypto
m3u8
aiofiles
m3u8~=0.8.0
aiofiles~=0.6.0
requests_async
requests[security]

0 comments on commit 054eddc

Please sign in to comment.