[Python] 纯文本查看 复制代码
import base64
import requests
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('hello')
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,
'#FORMAT':FORMAT,
'#DECMETHOD':DECMETHOD,
}
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:
r = requests.post('http://127.0.0.1:8787/', data=postdata)
if(r.json()['message']=='success'):
print('推送成功')
else:
print('推送失败')
except:
print('没有打开M3U8下载器吧?')
if __name__ == '__main__':
#参数对照逍遥一仙配置文件结构中所列出的可选参数给就行了,比如想改保存路径就传一个参数 OUT='D:\\test\\'
postToCuteM3U8(title='我是文件标题', m3u8Url='http://xxx.xxx.com/m3u8file.m3u8', KEY='2vi5S5yDJNRzgW4rhEX8A==',OUT='D:\\test\\')
postToCuteM3U8(title='我是文件标题', m3u8Url='http://xxx.xxx.com/m3u8file.m3u8')