mirror of
https://github.com/wbt5/real-url.git
synced 2025-07-31 22:13:05 +08:00
新增来疯直播弹幕
This commit is contained in:
parent
f24c64ca4b
commit
60393a00ef
@ -16,6 +16,7 @@ from .zhanqi import ZhanQi
|
|||||||
from .longzhu import LongZhu
|
from .longzhu import LongZhu
|
||||||
from .pps import QiXiu
|
from .pps import QiXiu
|
||||||
from .qf import QF
|
from .qf import QF
|
||||||
|
from .laifeng import LaiFeng
|
||||||
|
|
||||||
__all__ = ['DanmakuClient']
|
__all__ = ['DanmakuClient']
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ class DanmakuClient:
|
|||||||
'zhanqi.tv': ZhanQi,
|
'zhanqi.tv': ZhanQi,
|
||||||
'longzhu.com': LongZhu,
|
'longzhu.com': LongZhu,
|
||||||
'pps.tv': QiXiu,
|
'pps.tv': QiXiu,
|
||||||
'qf.56.com': QF}.items():
|
'qf.56.com': QF,
|
||||||
|
'laifeng.com': LaiFeng}.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
|
||||||
@ -61,7 +63,7 @@ class DanmakuClient:
|
|||||||
self.__ws = await self.__hs.ws_connect(ws_url)
|
self.__ws = await self.__hs.ws_connect(ws_url)
|
||||||
if reg_datas:
|
if reg_datas:
|
||||||
for reg_data in reg_datas:
|
for reg_data in reg_datas:
|
||||||
if self.__u == 'qf.56.com':
|
if self.__u == 'qf.56.com' or self.__u == 'laifeng.com':
|
||||||
await self.__ws.send_str(reg_data)
|
await self.__ws.send_str(reg_data)
|
||||||
else:
|
else:
|
||||||
await self.__ws.send_bytes(reg_data)
|
await self.__ws.send_bytes(reg_data)
|
||||||
@ -70,7 +72,7 @@ class DanmakuClient:
|
|||||||
while not self.__stop and self.__site.heartbeat:
|
while not self.__stop and self.__site.heartbeat:
|
||||||
await asyncio.sleep(self.__site.heartbeatInterval)
|
await asyncio.sleep(self.__site.heartbeatInterval)
|
||||||
try:
|
try:
|
||||||
if self.__u == 'qf.56.com':
|
if self.__u == 'qf.56.com' or self.__u == 'laifeng.com':
|
||||||
await self.__ws.send_str(self.__site.heartbeat)
|
await self.__ws.send_str(self.__site.heartbeat)
|
||||||
else:
|
else:
|
||||||
await self.__ws.send_bytes(self.__site.heartbeat)
|
await self.__ws.send_bytes(self.__site.heartbeat)
|
||||||
|
53
danmu/danmaku/laifeng.py
Normal file
53
danmu/danmaku/laifeng.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import aiohttp
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
class LaiFeng:
|
||||||
|
heartbeat = '2::'
|
||||||
|
heartbeatInterval = 30
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def get_ws_info(url):
|
||||||
|
rid = url.split('/')[-1]
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get('http://v.laifeng.com/') as resp:
|
||||||
|
imk = dict(resp.cookies)['imk'].value
|
||||||
|
args = {
|
||||||
|
'name': 'enter',
|
||||||
|
'args': [{
|
||||||
|
'token': imk.replace('%3D', '='),
|
||||||
|
'yktk': '',
|
||||||
|
'uid': '2082628924',
|
||||||
|
'isPushHis': '1',
|
||||||
|
'roomid': rid,
|
||||||
|
'endpointtype': 'ct_,dt_1_1003|0|_{}|CTaXF+oKpB4CAatxtZHBQchJ'.format(time.time() * 1e3)
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
reg_data = '5:::' + json.dumps(args)
|
||||||
|
return 'ws://normal01.chatroom.laifeng.com/socket.io/1/websocket/', [reg_data]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def decode_msg(message):
|
||||||
|
type_ = message[0]
|
||||||
|
msgs = []
|
||||||
|
msg = {'name': '', 'content': '', 'msg_type': 'other'}
|
||||||
|
if type_ == '5':
|
||||||
|
data = json.loads(message[4:])
|
||||||
|
name = data.get('name', 0)
|
||||||
|
args = data['args']
|
||||||
|
for arg in args:
|
||||||
|
if name == 'enterMessage': # 入场信息
|
||||||
|
msg['name'] = 'SYS'
|
||||||
|
msg['content'] = arg['body']['n'] + ' 进入频道'
|
||||||
|
msg['msg_type'] = 'danmaku'
|
||||||
|
elif name == 'globalHornMessage': # 系统消息
|
||||||
|
msg['name'] = 'SYS'
|
||||||
|
msg['content'] = arg['body']['m']
|
||||||
|
msg['msg_type'] = 'danmaku'
|
||||||
|
elif name == 'chatMessage': # 弹幕
|
||||||
|
msg['name'] = arg['body']['n']
|
||||||
|
msg['content'] = arg['body']['m']
|
||||||
|
msg['msg_type'] = 'danmaku'
|
||||||
|
msgs.append(msg.copy())
|
||||||
|
return msgs
|
@ -21,7 +21,7 @@ async def main(url):
|
|||||||
|
|
||||||
|
|
||||||
a = input('请输入直播间地址:\n')
|
a = input('请输入直播间地址:\n')
|
||||||
asyncio.run(main())
|
asyncio.run(main(a))
|
||||||
|
|
||||||
# 虎牙:https://www.huya.com/11352915
|
# 虎牙:https://www.huya.com/11352915
|
||||||
# 斗鱼:https://www.douyu.com/85894
|
# 斗鱼:https://www.douyu.com/85894
|
||||||
@ -31,9 +31,10 @@ asyncio.run(main())
|
|||||||
# 企鹅电竞: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
|
# 映客直播:https://www.inke.cn/liveroom/index.html?uid=87493223&id=1593906372018299
|
||||||
# CC直播:https://cc.163.com/363936598/
|
# CC直播:https://cc.163.com/363936598/a
|
||||||
# 酷狗直播:https://fanxing.kugou.com/1676290
|
# 酷狗直播:https://fanxing.kugou.com/1676290
|
||||||
# 战旗直播
|
# 战旗直播
|
||||||
# 龙珠直播:http://star.longzhu.com/wsde135864219
|
# 龙珠直播:http://star.longzhu.com/wsde135864219
|
||||||
# PPS奇秀直播:https://x.pps.tv/room/208337
|
# PPS奇秀直播:https://x.pps.tv/room/208337
|
||||||
# 搜狐千帆直播:https://qf.56.com/520208a
|
# 搜狐千帆直播:https://qf.56.com/520208a
|
||||||
|
# 来疯直播:https://v.laifeng.com/656428
|
||||||
|
Loading…
x
Reference in New Issue
Block a user