1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-28 03:20:31 +08:00

Compare commits

...

5 Commits

Author SHA1 Message Date
wbt5
656ddecd96 新增弹幕;更新虎牙 2020-07-05 09:58:59 +08:00
wbt5
527d296c9d 新增映客直播弹幕 2020-07-05 09:58:03 +08:00
wbt5
2f63951d68 新增映客直播弹幕 2020-07-05 09:57:32 +08:00
wbt5
3f90ae45c9 新增映客直播弹幕 2020-07-05 09:57:18 +08:00
wbt5
62ee879e21 更新虎牙直播源 2020-07-05 09:56:36 +08:00
5 changed files with 82 additions and 4 deletions

View File

@ -8,7 +8,7 @@
**26** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 look 直播、千帆直播。 **26** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 look 直播、千帆直播。
**5** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播。 **7** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播、企鹅电竞、花椒直播。
## 运行 ## 运行
@ -23,7 +23,9 @@
## 更新 ## 更新
### 2020.06.25:新增🐧企鹅电竞弹幕获取 ### 2020.07.05:新增花椒直播、映客直播弹幕获取;更新虎牙直播源
2020.06.25:新增🐧企鹅电竞弹幕获取
2020.06.19:新增火猫直播弹幕获取 2020.06.19:新增火猫直播弹幕获取

View File

@ -9,6 +9,7 @@ from .kuaishou import KuaiShou
from .huomao import HuoMao from .huomao import HuoMao
from .egame import eGame from .egame import eGame
from .huajiao import HuaJiao from .huajiao import HuaJiao
from .inke import Inke
__all__ = ['DanmakuClient'] __all__ = ['DanmakuClient']
@ -32,7 +33,8 @@ class DanmakuClient:
'huomao.com': HuoMao, 'huomao.com': HuoMao,
'kuaishou.com': KuaiShou, 'kuaishou.com': KuaiShou,
'egame.qq.com': eGame, 'egame.qq.com': eGame,
'huajiao.com': HuaJiao}.items(): 'huajiao.com': HuaJiao,
'inke.cn': Inke}.items():
if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url): if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url):
self.__site = s self.__site = s
self.__u = u self.__u = u
@ -84,10 +86,17 @@ class DanmakuClient:
await self.__dm_queue.put(m) await self.__dm_queue.put(m)
count += 1 count += 1
await self.heartbeats() await self.heartbeats()
async def init_ws_inke(self):
ws_url = await self.__site.get_ws_info(self.__url)
self.__ws = await self.__hs.ws_connect(ws_url)
await self.fetch_danmaku()
async def start(self): async def start(self):
if self.__u == 'huajiao.com': if self.__u == 'huajiao.com':
await self.init_ws_huajiao() await self.init_ws_huajiao()
elif self.__u == 'inke.cn':
await self.init_ws_inke()
else: else:
await self.init_ws() await self.init_ws()
await asyncio.gather( await asyncio.gather(

41
danmu/danmaku/inke.py Normal file
View File

@ -0,0 +1,41 @@
import aiohttp
import re
import time
import json
class Inke:
@staticmethod
async def get_ws_info(url):
uid = re.search(r'uid=(\d+)', url).group(1)
roomid = id = re.search(r'&id=(\d+)', url).group(1)
t = int(time.time() * 1e3)
cr = 'https://chatroom.inke.cn/url?roomid={}&uid={}&id={}&access_from=pc_web&_t={}'.format(roomid, uid, id, t)
async with aiohttp.ClientSession() as session:
async with session.get(cr) as resp:
res = await resp.text()
wss_url = json.loads(res).get('url')
return wss_url
@staticmethod
def decode_msg(data):
msgs = []
name = content = ''
msg_type = 'other'
message = json.loads(data)
ms = message['ms']
c = ms[-1].get('c', 0)
if c:
tp = ms[-1].get('tp', 0)
if tp == 'pub' or tp == 'color':
name = ms[0].get('from').get('nic', '')
elif tp == 'user_join_tip':
name = ms[0].get('u').get('nic', '')
else:
name = 'sys'
content = c
msg_type = 'danmaku'
msg = {'name': name, 'content': content, 'msg_type': msg_type}
msgs.append(msg)
return msgs

View File

@ -30,3 +30,4 @@ asyncio.run(main(a))
# 火猫: # 火猫:
# 企鹅电竞https://egame.qq.com/383204988 # 企鹅电竞https://egame.qq.com/383204988
# 花椒直播https://www.huajiao.com/l/303344861?qd=hu # 花椒直播https://www.huajiao.com/l/303344861?qd=hu
# 映客直播https://www.inke.cn/liveroom/index.html?uid=87493223&id=1593906372018299

27
huya.py
View File

@ -4,6 +4,30 @@
import requests import requests
import re import re
import base64
import urllib.parse
import hashlib
import time
def live(e):
i, b = e.split('?')
r = i.split('/')
s = re.sub(r'.(flv|m3u8)', '', r[-1])
c = b.split('&', 3)
c = [i for i in c if i != '']
n = {i.split('=')[0]: i.split('=')[1] for i in c}
fm = urllib.parse.unquote(n['fm'])
u = base64.b64decode(fm).decode('utf-8')
p = u.split('_')[0]
f = str(int(time.time() * 1e7))
l = n['wsTime']
t = '0'
h = '_'.join([p, t, s, f, l])
m = hashlib.md5(h.encode('utf-8')).hexdigest()
y = c[-1]
url = "{}?wsSecret={}&wsTime={}&u={}&seqid={}&{}".format(i, m, l, t, f, y)
return url
def get_real_url(room_id): def get_real_url(room_id):
@ -20,7 +44,8 @@ def get_real_url(room_id):
if 'replay' in liveLineUrl: if 'replay' in liveLineUrl:
return '直播录像:' + liveLineUrl return '直播录像:' + liveLineUrl
else: else:
real_url = ["https:" + re.sub(r'_\d{4}.m3u8', '.m3u8', liveLineUrl), "https:" + liveLineUrl] liveLineUrl = live(liveLineUrl)
real_url = ["https:" + liveLineUrl, "https:" + re.sub(r'_\d{4}.m3u8', '.m3u8', liveLineUrl)]
else: else:
real_url = '未开播或直播间不存在' real_url = '未开播或直播间不存在'
except: except: