钉钉直播权限破解下载教程
有时候群里面的直播下载权限不会打开,而录屏又比较耗费时间,这时候就可以使用抓包的方法下载直播。
抓包
点击群直播回放,会发现首先会请求一个m3u8格式的文件,其实也就是把原本的视频切成好多段来传输,其中的m3u8可以使用下载器来下载。你也可以自己以文本格式打开m3u8文件,发现有很多链接,一个一个下载后再用ffmpeg或者格式工厂处理,但是没有下载器快。!
在这之后的视频链接都在m3u8文件中:
下载
复制m3u8链接,粘贴至下载器中即可。
我在这之前写了个爬虫小程序来下载,下载速度可以但是视频拼接速度太慢,虽然下载下来m3u8文件可以直接点开(Potplayer支持),但是我还是没有使用,毕竟mp4主流一点,就直接用下载器了,这里放上代码
import requests
import tqdm
import os
requests.packages.urllib3.disable_warnings()
class Download:
def __init__(self):
self.headers = {
'Host': 'aliliving-pre.alicdn.com',
'Connection': 'keep-alive',
'Origin': 'https://h5.m.taobao.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 dingtalk-win/1.0.0 nw(0.14.7) DingTalk(5.0.11-Release.2) Mojo/1.0.0 Native AppType(release)',
'Accept': '*/*',
'Referer': 'https://h5.m.taobao.com/tblive/dingtalk/pc-playback.html',
# 'Accept-Encoding': 'gzip, deflate, br'
'Accept-Language': 'zh-CN,zh;q=0.9'
}
def download(self):
title = '''
*********************************
Dingtalk Download Tools v1.2.0
*********************************
During your use, please keep the Internet connected...
Help: Follow the instruction.
Hope you enjoy this program.
*********************************
'''
print(title)
m3u8 = input('url:')
text = self.get_text(m3u8)
vl = self.get_list(text, m3u8)
name = self.get_name()
print('\nStarting...\n')
self.save_file(name, vl)
print('\nFinishing...\n')
self.save_m3u8(text, name)
print('%s finish download...\nPlease continue...'%name)
def get_text(self, m3u8):
m = requests.get(m3u8, verify=False)
text = m.text.split("\n")
return text
def get_list(self, text, m3u8):
video_list = []
if 'aliliving-pre.alicdn.com/live_hp' in m3u8:
url = 'https://aliliving-pre.alicdn.com/live_hp/'
elif 'dtliving-pre.alicdn.com/live_hp' in m3u8:
url = 'https://dtliving-pre.alicdn.com/live_hp/'
elif 'dtliving-pre.alicdn.com/live/' in m3u8:
url = 'https://dtliving-pre.alicdn.com/live/'
elif 'aliliving-pre.alicdn.com/live/' in m3u8:
url = 'https://aliliving-pre.alicdn.com/live/'
else:
url = m3u8.split("?")[0].split('-')[0][:-8]
for each in text:
if '.ts' in each:
video_list.append(url+each)
return video_list
def get_name(self):
date = input('Date:')
subj = input('Subject:')
others = input('Others:')
return date + '_' + subj + '_' + others
def save_file(self, filename, video_list):
try:
os.mkdir('.\\%s' % filename)
except FileNotFoundError:
os.chdir('.\\%s' % filename)
except FileExistsError:
os.chdir('.\\%s' % filename)
else:
os.chdir('.\\%s' % filename)
i = 1
for each in tqdm.tqdm(video_list,ncols=72):
video = requests.get(each, verify=False)
with open(each.split('?')[0].split('/')[-1], 'wb') as video_file:
for chunk in video.iter_content(chunk_size=512):
video_file.write(chunk)
video_file.close()
# 这个地方注意一下:也可能你们的电脑内存大不会出现……
# Fiddler在抓包的时候如果不点Remove All或者按Ctrl+X一直不断抓包的话,
# 会把他抓的内容全部写进内存里,我用2GB内存的笔记本运行这个程序的时候经常会报错
# MemoryError,可能你们的电脑内存大就不会出现,抓包之后等下载完了一定要把Fiddler的抓包记录清理一下!!!
i += 1
os.chdir('..\\')
def save_m3u8(self, text, filename):
new_m3u8 = ''
for each in range(len(text)):
if '.ts' in text[each]:
add_text = "%s\%s"%(filename, text[each].split('?')[0].split('/')[-1])
new_m3u8 += add_text + '\n'
else:
new_m3u8 += text[each] + '\n'
with open('%s.m3u8' % (filename), 'w') as m3u8_file:
m3u8_file.write(new_m3u8)
m3u8_file.close()
if __name__ == '__main__':
while True:
download = Download()
download.download()
接下来是生成批处理文件处理下载好的m3u8转成mp4(不要这样因为真的很慢!!!),放上供参考。
import os
from xpinyin import Pinyin
p = Pinyin()
dirlist = os.listdir()
input_list = []
for each in dirlist:
if 'm3u8' in each:
try:
os.rename(each, p.get_pinyin(each))
except:
continue
print(each)
input_list.append(p.get_pinyin(each))
output = []
for each in input_list:
if ' ' in each:
print('error\n\n'+each+'\n\n')
output.append(p.get_pinyin(each.split('.')[0])+'.mp4')
bat = '''@echo off
echo Start Process...
'''
# 需要安装ffmpeg并添加至环境变量(不再赘述
for each in range(len(input_list)):
bat += 'ffmpeg -i %s %s\n' % (input_list[each], output[each])
bat += 'pause'
with open('process.bat', 'w') as f:
f.write(bat)
f.close()
其中拼音的包是用来把汉字转成拼音的,因为我用的时候发现ffmpeg不支持中文,再怎么切换编码都不行,害,没办法只能这样整了。
建议如果下载m3u8可以直接用格式工厂或者其它转格式工具,尽量不用命令行中的ffmpeg,也可能是我比较菜不太会用ffmpeg……
更建议直接找m3u8下载工具哈哈哈[doge]