-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaiziDownload.py
53 lines (38 loc) · 1.5 KB
/
maiziDownload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
'''
获取课程id的json请求URL
http://api.maiziedu.com/v2/getCareerDetail/?UUID=680c2c9cc8f147dc8b157b48aa9ddfc9&careerId=13&client=android
'''
import requests
import io
# 迅雷安装位置 这里要注意:安装位置要一定是英文的路径,中文的失败
download_exe = r'D:\Thunder9.1.22.538\Program\Thunder.exe'
# 视频储存位置
download_dir = ur'E:\maizi'
# 生成一个批处理文件
urls_bat = r'E:\click_to_download.bat'
# 此处为课程id列表(例如http://www.maiziedu.com/course/874)比如我现在要下载874和928的课程
course_id_list = [874, 928]
def download(course_id):
result = []
url = 'http://api.maiziedu.com/v2/getCoursePlayInfo/?courseId=%d&client=android' % course_id
r = requests.get(url)
json_data = r.json()
course_name = json_data['data']['course_name']
video_list = json_data['data']['video_list']
for video in video_list:
video_id = video['video_id']
video_name = video['video_name']
video_url = video['video_url']
cmd = ur'"%s" "%s" --file-allocation=none --max-connection-per-server=4 -d "%s\%s" -o "%d_%s.mp4"' \
% (download_exe, video_url, download_dir, course_name, video_id, video_name)
print cmd
result.append(cmd)
return result
result = []
for course_id in course_id_list:
result = result + download(course_id)
bat_file = io.open(urls_bat, 'w+', encoding='gbk')
for cmd in result:
bat_file.writelines(cmd + '\r\n')
bat_file.close()