厚大法考视频抓取制作播放列表
本帖最后由 创世2 于 2020-9-19 08:10 编辑最近朋友法考看视频刷题想要倍速,奈何网站播放器最高就二倍速。想着找找插件,没找见,就自己写了个小脚本,配合potplayer播放器,实现倍速播放。
在地址栏找到相关id,填入脚本即可在桌面输出.m3u的播放列表文件,导入potplayer即可播放。
正好需要的朋友可以下方自取:
蓝奏云:https://wwa.lanzouj.com/iCTwYgqskdi
源码如下(写的很菜):
import requests
import os
def get_classid(pc_id):
headers = {
'Host': 'www.houdask.com',
'Connection': 'keep-alive',
'Content-Length': '0',
'Accept': 'application/json, text/plain, */*',
'Origin': 'http://www.houdask.com',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36',
'Referer': 'http://www.houdask.com/site/hd/resources/views/free/play.html?id=8145&type=1',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
params = (
('data', '{"courseType":"1","videoId":%s}' % pc_id),
)
response = requests.post('http://www.houdask.com/api/other/freeclassvideo/anon/pc/video/get/details', headers=headers, params=params)
class_id = response.json()["data"]["classVideo"]["classId"]
return class_id
def spide_adress(pc_id):
name_list = []
adress_list = []
num = 0
headers = {
'Host': 'www.houdask.com',
'Connection': 'keep-alive',
'Content-Length': '36',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Origin': 'http://www.houdask.com',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'http://www.houdask.com/site/hd/resources/wap/play.html?classId=499',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
}
data = {
'data': '{"classId":%s}'% get_classid(pc_id)
}
response = requests.post('http://www.houdask.com/api/other/freeclassvideo/anon/wap/video/get/details/list', headers=headers, data=data)
# response.json() 获取响应的json数据 数据类型为字典
response_json = response.json()
video_list = response_json["data"]["videoList"]
tictle = response_json["data"]["phaseName"]
# print(type(response_json), type(video_list["videoName"]), type(tictle))
for every_dict in video_list:
name = every_dict["videoName"]
video_adress = every_dict["video"]
name_list.append(name)
adress_list.append(video_adress)
num = num + 1
return name_list, adress_list, tictle, num
def write_file(name_list, adress_list, tictle, num):
with open(r'{}\Desktop\{}-{}.m3u'.format(os.environ.get('USERPROFILE'), tictle, name_list), 'w', encoding='utf-8')as f:
f.write('#EXTM3U' + '\n')
for index, name in enumerate(name_list):
f.write('#EXTINF:0' + ',' + name + '\n')
f.write(adress_list + '\n')
if __name__ == "__main__":
pc_id = str(input('请输入视频Id:'))
name_list, adress_list, tictle, num = spide_adress(pc_id)
write_file(name_list, adress_list, tictle, num)
print('播放列表文件创建成功')
print('===============================')
input('按任意键推出') 细水流长 发表于 2020-9-18 21:58
方便发下源码吗?
我编辑一下,写的很菜 谢谢分享 创世2 发表于 2020-9-18 22:00
我编辑一下,写的很菜
楼主你的cookie泄露出来了,会不会有影响啊{:301_971:}{:301_971:} 用着不错哦 支持!! 感谢分享,对法学类是有点兴趣,但是看到板砖一样厚的书,就头大了,也许换视频的方式会消除一点恐惧感吧。收藏从未停止,学习从未开始{:301_971:} 不想当咸鱼 发表于 2020-9-18 22:45
楼主你的cookie泄露出来了,会不会有影响啊
没登陆的 应该没什么问题
页:
[1]