mirror of
https://github.com/wbt5/real-url.git
synced 2025-08-02 07:12:37 +08:00
新增5个平台弹幕功能
This commit is contained in:
parent
022929fef3
commit
aad15f17b1
@ -11,6 +11,11 @@ from .egame import eGame
|
|||||||
from .huajiao import HuaJiao
|
from .huajiao import HuaJiao
|
||||||
from .inke import Inke
|
from .inke import Inke
|
||||||
from .cc import CC
|
from .cc import CC
|
||||||
|
from .kugou import KuGou
|
||||||
|
from .zhanqi import ZhanQi
|
||||||
|
from .longzhu import LongZhu
|
||||||
|
from .pps import QiXiu
|
||||||
|
from .qf import QF
|
||||||
|
|
||||||
__all__ = ['DanmakuClient']
|
__all__ = ['DanmakuClient']
|
||||||
|
|
||||||
@ -36,7 +41,12 @@ class DanmakuClient:
|
|||||||
'egame.qq.com': eGame,
|
'egame.qq.com': eGame,
|
||||||
'huajiao.com': HuaJiao,
|
'huajiao.com': HuaJiao,
|
||||||
'inke.cn': Inke,
|
'inke.cn': Inke,
|
||||||
'cc.163.com': CC}.items():
|
'cc.163.com': CC,
|
||||||
|
'fanxing.kugou.com': KuGou,
|
||||||
|
'zhanqi.tv': ZhanQi,
|
||||||
|
'longzhu.com': LongZhu,
|
||||||
|
'pps.tv': QiXiu,
|
||||||
|
'qf.56.com': QF}.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
|
||||||
@ -49,14 +59,21 @@ class DanmakuClient:
|
|||||||
async def init_ws(self):
|
async def init_ws(self):
|
||||||
ws_url, reg_datas = await self.__site.get_ws_info(self.__url)
|
ws_url, reg_datas = await self.__site.get_ws_info(self.__url)
|
||||||
self.__ws = await self.__hs.ws_connect(ws_url)
|
self.__ws = await self.__hs.ws_connect(ws_url)
|
||||||
for reg_data in reg_datas:
|
if reg_datas:
|
||||||
await self.__ws.send_bytes(reg_data)
|
for reg_data in reg_datas:
|
||||||
|
if self.__u == 'qf.56.com':
|
||||||
|
await self.__ws.send_str(reg_data)
|
||||||
|
else:
|
||||||
|
await self.__ws.send_bytes(reg_data)
|
||||||
|
|
||||||
async def heartbeats(self):
|
async def heartbeats(self):
|
||||||
while not self.__stop:
|
while not self.__stop and self.__site.heartbeat:
|
||||||
await asyncio.sleep(self.__site.heartbeatInterval)
|
await asyncio.sleep(self.__site.heartbeatInterval)
|
||||||
try:
|
try:
|
||||||
await self.__ws.send_bytes(self.__site.heartbeat)
|
if self.__u == 'qf.56.com':
|
||||||
|
await self.__ws.send_str(self.__site.heartbeat)
|
||||||
|
else:
|
||||||
|
await self.__ws.send_bytes(self.__site.heartbeat)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -70,7 +87,7 @@ class DanmakuClient:
|
|||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await self.init_ws()
|
await self.init_ws()
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def init_ws_huajiao(self):
|
async def init_ws_huajiao(self):
|
||||||
rid = re.search(r'\d+', self.__url).group(0)
|
rid = re.search(r'\d+', self.__url).group(0)
|
||||||
s = self.__site(rid)
|
s = self.__site(rid)
|
||||||
@ -88,17 +105,10 @@ 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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user