1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-08-04 09:22:47 +08:00

Compare commits

...

7 Commits

Author SHA1 Message Date
wbt5
265e1a6a2d Create .gitignore 2020-06-19 22:41:44 +08:00
wbt5
7633e90118 update 2020-06-19 22:40:18 +08:00
wbt5
abcd4c9a1a update 2020-06-19 22:36:45 +08:00
wbt5
1674db7eb2 update 2020-06-19 22:31:13 +08:00
乌帮图
60c8ba5b72
Delete .gitignore 2020-06-19 22:28:56 +08:00
乌帮图
17924159a1
Create .gitignore 2020-06-19 22:24:56 +08:00
wbt5
9f2d7f6e6b 新增火猫直播弹幕 2020-06-19 22:22:47 +08:00
15 changed files with 57 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*/__pycache__/

View File

@ -8,7 +8,7 @@
**26** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 look 直播、千帆直播。 **26** 个直播平台的直播源获取:斗鱼直播、虎牙直播、哔哩哔哩直播、战旗直播、网易 CC 直播、火猫直播、企鹅电竞、YY 直播、一直播、快手直播、花椒直播、映客直播、西瓜直播、触手直播、NOW 直播、抖音直播爱奇艺直播、酷狗直播、龙珠直播、PPS 奇秀直播、六间房、17 直播、来疯直播、优酷轮播台、网易 look 直播、千帆直播。
**4** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播。 **5** 个直播平台的弹幕获取:斗鱼直播、虎牙直播、哔哩哔哩直播、快手直播、火猫直播。
## 运行 ## 运行
@ -23,7 +23,9 @@
## 更新 ## 更新
### 2020.06.18:新增弹幕功能 ### 2020.06.19:新增火猫直播弹幕获取
2020.06.18:新增弹幕功能
- 添加斗鱼、虎牙、哔哩哔哩和快手 4 个平台的弹幕获取。后续添加其他平台。 - 添加斗鱼、虎牙、哔哩哔哩和快手 4 个平台的弹幕获取。后续添加其他平台。
- 实现弹幕功能的代码和思路主要来自:[danmaku](https://github.com/IsoaSFlus/danmaku) 和 [ks_barrage](https://github.com/py-wuhao/ks_barrage),感谢两位大佬! - 实现弹幕功能的代码和思路主要来自:[danmaku](https://github.com/IsoaSFlus/danmaku) 和 [ks_barrage](https://github.com/py-wuhao/ks_barrage),感谢两位大佬!

View File

@ -6,6 +6,7 @@ from .bilibili import Bilibili
from .douyu import Douyu from .douyu import Douyu
from .huya import Huya from .huya import Huya
from .kuaishou import KuaiShou from .kuaishou import KuaiShou
from .huomao import HuoMao
__all__ = ['DanmakuClient'] __all__ = ['DanmakuClient']
@ -26,7 +27,8 @@ class DanmakuClient:
for u, s in {'douyu.com': Douyu, for u, s in {'douyu.com': Douyu,
'live.bilibili.com': Bilibili, 'live.bilibili.com': Bilibili,
'huya.com': Huya, 'huya.com': Huya,
'kuaishou.com': KuaiShou}.items(): 'huomao.com': HuoMao,
'kuaishou.com': KuaiShou,}.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
break break

49
danmu/danmaku/huomao.py Normal file
View File

@ -0,0 +1,49 @@
import struct
import aiohttp
import json
class HuoMao:
heartbeat = b'\x00\x00\x00\x10\x00\x10\x00\x01\x00\x00\x00\x02\x00\x00\x00\x01'
# heartbeat = struct.pack('!ihhii', 16,16,1,2,1)
heartbeatInterval = 30
@staticmethod
async def get_ws_info(url):
goim = 'http://www.huomao.com/ajax/goimConf?type=h5'
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, '
'like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'}
async with aiohttp.ClientSession() as session:
async with session.get(goim, headers=headers) as resp:
info = json.loads(await resp.text())
webSocketUrls = info.get('host_wss', 0)
rid = int(url.split('/')[-1])
reg_datas = []
tokenBody = json.dumps({"Uid": 0, "Rid": rid}, separators=(',', ':'))
bodyBuf = tokenBody.encode('ascii')
headerBuf = struct.pack('!ihhii', (16 + len(bodyBuf)), 16, 1, 7, 1)
data = headerBuf + bodyBuf
reg_datas.append(data)
return webSocketUrls, reg_datas
@staticmethod
def decode_msg(data):
packetLen, headerLen, ver, op, seq = struct.unpack('!ihhii', data[0:16])
msgs = []
msg = {'name': '', 'content': '', 'msg_type': 'other'}
if op == 5:
offset = 0
while offset < len(data):
packetLen, headerLen, ver = struct.unpack('!ihh', data[offset:(offset + 8)])
msgBody = data[offset + headerLen:offset + packetLen]
offset += packetLen
body = json.loads(msgBody.decode('utf8'))
if body.get('code', 0) == '100001':
msg['name'] = body['speak']['user']['name']
msg['content'] = body['speak']['barrage']['msg']
msg['msg_type'] = 'danmaku'
msgs.append(msg.copy())
return msgs
msgs.append(msg)
return msgs