不知道是不是我对m3u8理解不够,某些网站爬取的m3u8长期有效,某些网站只有一两个小时有效期,针对这种有效期短的网站,又想爬取它全部视频
逍遥大神的软件说明
https://www.52pojie.cn/forum.php?mod=viewthread&tid=1631141&highlight=m3u8%C5%FA%C1%BF%CF%C2%D4%D8
python调用
https://www.52pojie.cn/thread-1216587-1-1.html
[Python] 纯文本查看 复制代码 import base64
import requests
import time
def postToCuteM3U8(title, m3u8Url, HEAD='', OUT='', NFAIL=0, CLOSE=0, CHECK=0, KEY='', CACHE=0, NKEY=0, NETCHECK=0, NTSCHECK=0, IDOWN=0, NCONCAT=0, AGENT='', FORMAT='mp4', DECMETHOD='cbc', **kwargs):
print('调用下载器')
data = {
'#HEAD': HEAD,
'#OUT': OUT,
'#NFAIL': NFAIL,
'#CLOSE': CLOSE,
'#CHECK': CHECK,
'#KEY': KEY,
'#CACHE': CACHE,
'#NKEY': NKEY,
'#NETCHECK': NETCHECK,
'#NTSCHECK': NTSCHECK,
'#IDOWN': IDOWN,
'#NCONCAT': NCONCAT,
'#AGENT': AGENT
}
datastr = ''
for key in data.keys():
# print(key,data[key])
if (data[key]):
datastr = datastr + str(key) + ',' + str(data[key]) + '\r\n'
datastr = datastr + title + ',' + m3u8Url # datastr是配置内容
postdata = {
"data": datastr,
"type": '2' # 模式2
}
try:
rr = requests.post('http://127.0.0.1:8787/info')
if (rr.json()['failTotal'] > 20):
print("超过20条异常数据时终止运行")
return 0
elif (rr.json()['queueTotalReal'] < 70):
r = requests.post('http://127.0.0.1:8787/', data=postdata)
if (r.json()['message'] == 'success'):
print('推送成功')
else:
print('推送失败')
return 1
else:
print("已有70条数据执行休息半小时")
time.sleep(30 * 60)
r = requests.post('http://127.0.0.1:8787/', data=postdata)
if (r.json()['message'] == 'success'):
print('推送成功')
else:
print('推送失败')
return 2
except:
print('没有打开M3U8下载器吧?')
return 0
水平差大家凑合着用,根据返回状态码再做处理
对于这种有效期短的m3u8,有大神指点下更好的解决方法吗
|