1 Star 0 Fork 1

cc/IPTV

forked from UndCover/IPTV 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wafm.py 2.20 KB
一键复制 编辑 原始数据 按行查看 历史
UndCover 提交于 2020-07-10 10:27 . update wafm.py
import requests
# 导入文件操作库
import os
import re
import bs4
import json
from bs4 import BeautifulSoup
# mainUrl = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?id=TOPC1569314345479107&n=100&sort=desc&p={}&mode=2&serviceId=tvcctv&d={}'.format
mainUrl = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?id=TOPC1451557970755294&n=100&sort=desc&p={}&mode=2&serviceId=tvcctv&d={}'.format
url = 'http://newcntv.qcloudcdn.com/asp/hls/main/0303000a/3/default/{}/main.m3u8?maxbr=2048'.format
target = 'http://newcntv.qcloudcdn.com/asp/hls/2000/0303000a/3/default/4745f57fb4c14415b60c3f6df3db5624/2000.m3u8'
# url2 = 'http://newcntv.qcloudcdn.com/asp/hls/main/0303000a/3/default/{0}/main.m3u8?maxbr=2048'
mainPath = 'wafm(old){}.m3u'.format
global proxies
proxies = {
'http':'http://athena05:808',
'https':'https://athena05:808'
}
def lineParse(_url):
res_sub = requests.get(_url,proxies=proxies)
res_sub.encoding = 'utf-8'
tList = re.findall(r'/[^\s]*', res_sub.text)
targetLink = ''
fMax = 0
for i in range(len(tList)):
item = re.findall(r'[1-9]\d*(?=\.)', tList[i])
tMax = int(item[0])
if(fMax < tMax):
targetLink = tList[i]
fMax = tMax
print(targetLink)
return targetLink
def mainParse(_url,_path):
print("request-------------------------\n"+_url)
res_sub = requests.get(_url,proxies=proxies)
res_sub.encoding = 'utf-8'
jo = json.loads(res_sub.text)
jData = jo['data']
jList = jData['list']
if(len(jList) == 0):
return False
f = open(_path, 'a+', encoding='utf-8')
for i in range(len(jList)):
tGuid =jList[i]['guid']
tTitle = jList[i]['title']
f.write('#EXTINF:-1 , group-title="我爱发明", ')
f.write(tTitle)
f.write('\nhttp://newcntv.qcloudcdn.com')
f.write(lineParse(url(tGuid)))
f.write('\n')
f.close()
print("done")
return True
if __name__ == '__main__':
# mainParse(mainUrl)
# lineParse(url('4745f57fb4c14415b60c3f6df3db5624'))
for y in reversed(range(2009,2021)):
i = 1
while mainParse(mainUrl(i,y),mainPath(y)):
i = i + 1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cjcv/iptv.git
git@gitee.com:cjcv/iptv.git
cjcv
iptv
IPTV
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385