吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2894|回复: 71
上一主题 下一主题
收起左侧

[Python 原创] 咪咕直播源获取

  [复制链接]
跳转到指定楼层
楼主
caliph21 发表于 2024-3-12 17:09 回帖奖励
[Python] 纯文本查看 复制代码
#此工具实时获取咪咕视频的直播地址
#存至./lives/migu.txt 可以直接用TVBox APP配置
#http://127.0.0.1:9978/file/TVBoxx/MeowTV/TVBoxx/lives/migu.txt (wifi:9979)
#http://127.0.0.1:9978/file/[等于手机的/sfcard]
#/storage/emulated/0/
#此工具的保存路径/TVBoxx/MeowTV/TVBoxx/自己随便修改
#有时效性:大概4小时或更长,具体的自行测试
#不卡不卡不卡,重要的事说三遍


##关于咪咕视频的m3u8再次解析##
#https://blog.csdn.net/chouzhou9701/article/details/119260799
import requests,json,time,random
from urllib import parse
from pprint import pprint
#全部频道:https://m.miguvideo.com/m/home/f08583e602f846a5b870f3de3b673326?plt=sub&channelId=10010001005
def get_topVomsID():
	#央视的vomsID:
	url='https://program-sc.miguvideo.com/live/v2/tv-data/a5f78af9d160418eb679a6dd0429c920'
	res=requests.get(url,headers=headers)
	res_js=json.loads(res.text)['body']
	livelist=res_js['liveList']
	#all:['热门', '体育', '央视', '卫视', '地方', '影视', '新闻', '教育', ' 熊猫', '娱乐', '少儿', '纪实', '印象天下', '电台']
	mychannels=['热门',  '体育', '央视', '卫视', '影视']
	#自选频道
	#print(livelist)
	#nowVomsId=res_js['nowVomsId']
	top_names,vomsIDs=[],[]
	for list in livelist:
		top_name,vomsID=list['name'],list['vomsID']
		if top_name in mychannels:
			top_names.append(top_name)
			vomsIDs.append(vomsID)
	print(f'自选频道 :{top_names}')
	return top_names,vomsIDs
	
def get_tv_id(id):
	#CCTV节目列表now|next,图标,pID,name
	#央视:
	url=f'https://program-sc.miguvideo.com/live/v2/tv-data/{id}'
	#print(url)
	res=requests.get(url,headers=headers)
	res_js=json.loads(res.text)['body']		
	datalist=res_js['dataList']
	names,pIDs=[],[]
	for data in datalist:
		name=data['name']
		pID=data['pID']
		names.append(name)
		pIDs.append(pID)
		nw=data.get('now','')
		if nw!='':
			now=nw['startTime']+'-'+nw['endTime']+' '+nw['playName']
			if 'next' in data:
				nt=data['next']
				next=nt['startTime']+'-'+nt['endTime']+' '+nt['playName']
				print(name,pID,now,next)
			else:print(name,pID,now)
	return names,pIDs
	
def get_play_url(pIDs):
	#print(pIDs)
	h5_urls=[]
	for id in pIDs:
		#print(id)
		#rateType=3高清
		#print(id)#直播"pID":"608807420"
		url=f'https://webapi.miguvideo.com/gateway/playurl/v3/play/playurl?contId={id}&rateType=3&startPlay=true'	
		#url='http://webapi.miguvideo.com/gateway/playurl/v2/play/playurlh5?contId=635491149&rateType=3&startPlay=true'
		#url='https://webapi.miguvideo.com/gateway/playurl/v3/play/playurl?contId=635491149&rateType=3&startPlay=true'
		#'http://webapi.miguvideo.com/gateway/playurl/v2/play/playurlh5?contId=631780532&rateType=3&clientId=5e31849abe9be8ad087ca5fbd67b0e14&startPlay=true&xh265=false&channelId=0131_10010001005'
		#time.sleep(1)
		res=requests.get(url,headers=headers)
		play_jsons=json.loads(res.text)##仅一个源
		message=play_jsons["message"]
		if message=="SUCCESS":
			#pprint(play_jsons)
			h5_url=play_jsons['body']['urlInfo']['url']
			#TypeError: 'NoneType' 版权限制访问#cctv1608807420
			h5_urls.append(h5_url)
		else:
			print(f'ID:{id} ,版权限制,无法观看')
			h5_urls.append('error')			
	return h5_urls

def ddCalcu(url):
    #play_url再次解析getm3u8地址
    new_url = parse.urlparse(url)
    #print(new_url)
    para = dict(parse.parse_qsl(new_url.query))
    #print(para)
    userid = para.get("userid","")
    timestamp = para.get("timestamp","")
    ProgramID = para.get("ProgramID","")
    Channel_ID = para.get("Channel_ID","")
    puData = para.get("puData","")
    t = userid if userid else "eeeeeeeee" 
    r = timestamp if timestamp else "tttttttttttttt"
    n = ProgramID if ProgramID else "ccccccccc"
    a = Channel_ID if Channel_ID else "nnnnnnnnnnnnnnnn"
    o = puData if puData else ""
    if not o:
        return url
    s = list("2624")
    u = list(t)[int(s[0])] or "e"
    l = list(r)[int(s[1])] or "t"
    c = list(n)[int(s[2])] or "c"
    f = list(a)[len(a)-int(s[3])] or "n"
    d = list(o)
    h = []
    p = 0
    #print(p*2 < len(d))
    while p*2 < len(d):
        h.append(d[len(d)-p-1])
        if p < len(d) - p -1:
            h.append(o[p])
        if p == 1:
            h.append(u)
        if p == 2:
            h.append(l)
        if p == 3:
            h.append(c)
        if p == 4:
            h.append(f)
        p += 1
    v = "".join(h)
    return url + "&ddCalcu=" + v

def api(new_url):
	#第三次解析
	headers={
	'Host':'h5live.gslb.cmvideo.cn',
	'Connection': 'keep-alive',
	'Accept': 'text/plain, */*; q=0.01',
	'X-Requested-With': 'mark.via',
	'Accept-Encoding': 'gzip, deflate',
	'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
	'Origin':'http://m.miguvideo.com',
	'Referer':'http://m.miguvideo.com/',
	'User-Agent':'Mozilla/5.0 (Linux; Android 10; SP300 Build/CMDCSP300;) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.105 Mobile Safari/537.36'}
	#param={'crossdomain':'www'}
	time.sleep(1)
	#104:网路连接异常try
	#requests.exceptions.ConnectionError:
	try:
		res=requests.get(new_url,headers=headers,timeout=10)
		#print(res.status_code)
		m3u8=str(res.text)
		return m3u8
	except requests.exceptions.ConnectionError as e:
	    print('&#10008;网络连接异常: ', e)
	    return False
	except requests.exceptions.Timeout as e:
	    print('&#10008;连接超时: ',e)
	except requests.exceptions.RequestException as e:
	    print('&#10008;请求异常: ', e)
	except requests.exceptions.HTTPError as e:
	    print(f'&#10008;HTTP错误, 状态码: {e.response.status_code}, {e}')
	except ValueError as e:
	    print('&#10008;响应解析异常: ', e)
	
def run():
	top_vmos=get_topVomsID()
	top_names,vomsIDs=top_vmos[0],top_vmos[1]
	
	ftime = time.strftime("%Y%m%d %H:%M", time.localtime())
	s='&#127880;&#129419;&#129436;&#127808;&#128139;&#127908;&#127895;&#127894;\
&#127941;&#10024;&#127883;&#127795;&#127811;&#127793;&#127807;&#9752;&#128165;\
&#129351;&#129352;&#129353;&#127801;&#127989;&#65039;&#127810;&#127802;&#127885;&#127796;'
	
	f=open('lives/migu.txt','w+')
	f.write(f'&#127894;咪咕直播源,#genre#\n')
	f.write(f'by caliph21_{ftime}更新 ,https://15799848.s21v.faiusr.com/58/ABUIABA6GAAgr-2n9AUoqsakNg.mp4\n')
	f.write('串烧,https://vd4.bdstatic.com/mda-mkn4iq79ihtufbc1/sc/cae_h264/1637639849265611965/mda-mkn4iq79ihtufbc1.mp4\n\n')
	f.close()
	for i in range(len(vomsIDs)):
		pic=random.choice(s)
		top_name=top_names[i]
		print('\n',top_name,f'{i+1}/{len(vomsIDs)}')
		#time.sleep(1)
		tv_id=get_tv_id(vomsIDs[i])
		print('\n')
		#time.sleep(1)
		h5_urls=get_play_url(tv_id[1])

		f=open('lives/migu.txt','a+')
		f.write(f'{pic}|{top_name},#genre#\n\n')
		f.close()

		for name,url in zip(tv_id[0],h5_urls):
			#print(url)
			if url!='error':
				new_url=ddCalcu(url)
				#print(new_url)
				#time.sleep(1)
				m3u8=api(new_url+'&crossdomain=www')
				#print(url==new_url)
				if m3u8!=False:
					#剔除104网路连接异常
					print(f'正在更新源: {name} ……')
					#print(m3u8)
					with open('lives/migu.txt','a+') as f:
						f.write(name+','+str(m3u8)+'\n')
						f.close()
		
	

if __name__ == '__main__':
    #names,pIDs=[],[]
    headers={'User-Agent':'Mozilla/5.0 (Linux; Android 10; SP300 Build/CMDCSP300;) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/93.0.4515.105 Mobile Safari/537.36'}
    run()
    #url = "https://h5live.gslb.cmvideo.cn/migu/kailu/20200324/cctv4meihd/50/index.m3u8?msisdn=20231224165648c5b9040c723843188ccd7b0e30f81b36&mdspid=&spid=699004&netType=0&sid=2200179344&pid=2028597139×tamp=20231224165648&Channel_ID=0116_25000000-99000-100300010010001&ProgramID=608807416&ParentNodeID=-99&assertID=2200179344&client_ip=240e:478:4840:1642:17a3:aca9:695:be83&SecurityKey=20231224165648&promotionId=&mvid=2200179344&mcid=500020&playurlVersion=WX-A1-6.12.1.1-RELEASE&userid=&jmhm=&videocodec=h264&bean=mgsph5&puData=8c5826a81b06fdc46a46a9128be66cd0"
    #url='https://h5live.gslb.cmvideo.cn/wd_r2/cctv/cctv1hd/600/index.m3u8?msisdn=202312241405015bc0ae24f1bb42dc9e16ff0f7ac931f9&mdspid=&spid=699004&netType=0&sid=2201057821&pid=2028597139×tamp=20231224140501&Channel_ID=0116_25000000-99000-100300010010001&ProgramID=608807420&ParentNodeID=-99&assertID=2201057821&client_ip=240e:478:4840:1642:17a3:aca9:695:be83&SecurityKey=20231224140501&promotionId=&mvid=2201057821&mcid=500020&playurlVersion=WX-A1-6.12.1.1-RELEASE&userid=&jmhm=&videocodec=h264&bean=mgsph5&puData=3f841e2a0b365c2914ee68cd75073bdb'
    #new_url = ddCalcu(url)
    #print(new_url)
    #from transformers import CLIPModel
    #model = CLIPModel.from_pretrained("openai/clip-vit-large-patch14", from_tf=True)



免费评分

参与人数 12吾爱币 +17 热心值 +11 收起 理由
imNOTHING + 1 + 1 谢谢@Thanks!
ytt521 + 1 鼓励转贴优秀软件安全工具和文档!
zd694272892 + 1 谢谢@Thanks!
healwilson + 1 + 1 谢谢@Thanks!
sheeponeone + 1 谢谢@Thanks!
LeeKitch + 1 + 1 鼓励转贴优秀软件安全工具和文档!
FMJ123 + 1 + 1 我很赞同!
小空520 + 2 + 1 谢谢@Thanks!
庸世俗人罢勒 + 1 + 1 亲测好用
swydcyy + 1 + 1 谢谢@Thanks!
爱飞的猫 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
asus21 + 1 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
andyle 发表于 2024-3-12 18:23
本帖最后由 andyle 于 2024-3-12 21:30 编辑

真的可以吗,这个厉害了,我放进自建源了,但是显示不正常的频道看着五六十个,但是显示都不正常的,貌似也只有一个频道是可以播放的
推荐
a_wei78 发表于 2024-4-8 23:21
其ddCalcu加密方法已置于wasm模块中,此代码已失效
沙发
 楼主| caliph21 发表于 2024-3-12 17:14 |楼主
自选频道 :['热门', '体育', '央视', '卫视', '影视']

热门 1/5
湖南卫视 635491149 17:11-17:56 青春独播剧场:以家人之名(22) 17:56-18:30 新闻大求真
东方卫视 651632648 12:27-17:22 《人世间》(36-42) 17:22-17:38 百视大看点
江苏卫视 623899368 17:03-18:00 长风渡 18:00-18:30 新闻眼
CCTV1综合 608807420 13:13-17:17 一路向前8-12 17:17-17:38 第一动画乐园-2024-97
CCTV13新闻 608807423 17:00-18:00 新闻直播间 18:00-19:00 共同关注
CCTV5体育 641886683 16:30-18:00 实况录像-2024年世界室内田径锦标赛 2 18:00-18:33 体育新闻
CCTV5+体育赛事 641886773 16:33-18:00 实况录像-2023/2024中国男子篮球职业联赛常规赛 第42轮 广州龙狮—上海久事 18:00-19:30 国际足球赛场-23-24赛季英超联赛第28轮 布赖顿—诺丁汉森林
CCTV6电影 624878396 16:03-18:19 平原枪声 18:19-20:18 太行山上
CCTV8电视剧 624878356 16:28-19:20 最美的青春15-17 19:20-19:30 星推 荐-2024年3月-12
CCTV4中文国际 631780421 17:11-17:15 荟萃节目-秘境之眼5 17:15-18:00 远方的家2024-19(4K)
CCTV10科教 624878405 17:01-17:27 跟着书本去旅行-2024-51 17:27-18:05 地理·中国-2024-72
CCTV12社会与法 673168185 16:57-17:29 天网-2024-51 17:29-18:20 方圆 剧阵2024-71


ID:635491149 ,版权限制,无法观看
ID:651632648 ,版权限制,无法观看
正在更新源: 江苏卫视 ……
正在更新源: CCTV1综合 ……
正在更新源: CCTV13新闻 ……
正在更新源: CCTV5体育 ……


其他的直接修改自己需要的频道
3#
Cyberpunk2077 发表于 2024-3-12 17:16
亲测可用
4#
pojie1217 发表于 2024-3-12 17:33
大神,正需要看直播
5#
 楼主| caliph21 发表于 2024-3-12 17:41 |楼主

失效了,再跑一下,省的全世界找直播源
6#
Marken888 发表于 2024-3-12 17:51
感谢方法分享!
7#
asus21 发表于 2024-3-12 17:59
楼主倾囊相授,收藏了
9#
 楼主| caliph21 发表于 2024-3-12 18:31 |楼主
andyle 发表于 2024-3-12 18:23
真的可以吗,这个厉害了

必须&#127568;
10#
 楼主| caliph21 发表于 2024-3-12 18:36 |楼主

共同进步
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-27 17:02

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表