釘釘直播權限破解下載教程
有時候群里面的直播下載權限不會打開,而錄屏又比較耗費時間,這時候就可以使用抓包的方法下載直播。
抓包
點擊群直播回放,會發現首先會請求一個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]