mirror of
https://github.com/wbt5/real-url.git
synced 2025-06-17 08:25:25 +08:00
Compare commits
5 Commits
4791d0a68f
...
656ddecd96
Author | SHA1 | Date | |
---|---|---|---|
|
656ddecd96 | ||
|
527d296c9d | ||
|
2f63951d68 | ||
|
3f90ae45c9 | ||
|
62ee879e21 |
@ -8,7 +8,7 @@
|
||||
|
||||
**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:新增火猫直播弹幕获取
|
||||
|
||||
|
@ -9,6 +9,7 @@ from .kuaishou import KuaiShou
|
||||
from .huomao import HuoMao
|
||||
from .egame import eGame
|
||||
from .huajiao import HuaJiao
|
||||
from .inke import Inke
|
||||
|
||||
__all__ = ['DanmakuClient']
|
||||
|
||||
@ -32,7 +33,8 @@ class DanmakuClient:
|
||||
'huomao.com': HuoMao,
|
||||
'kuaishou.com': KuaiShou,
|
||||
'egame.qq.com': eGame,
|
||||
'huajiao.com': HuaJiao}.items():
|
||||
'huajiao.com': HuaJiao,
|
||||
'inke.cn': Inke}.items():
|
||||
if re.match(r'^(?:http[s]?://)?.*?%s/(.+?)$' % u, url):
|
||||
self.__site = s
|
||||
self.__u = u
|
||||
@ -84,10 +86,17 @@ class DanmakuClient:
|
||||
await self.__dm_queue.put(m)
|
||||
count += 1
|
||||
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):
|
||||
if self.__u == 'huajiao.com':
|
||||
await self.init_ws_huajiao()
|
||||
elif self.__u == 'inke.cn':
|
||||
await self.init_ws_inke()
|
||||
else:
|
||||
await self.init_ws()
|
||||
await asyncio.gather(
|
||||
|
41
danmu/danmaku/inke.py
Normal file
41
danmu/danmaku/inke.py
Normal 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
|
@ -30,3 +30,4 @@ asyncio.run(main(a))
|
||||
# 火猫:
|
||||
# 企鹅电竞:https://egame.qq.com/383204988
|
||||
# 花椒直播:https://www.huajiao.com/l/303344861?qd=hu
|
||||
# 映客直播:https://www.inke.cn/liveroom/index.html?uid=87493223&id=1593906372018299
|
||||
|
27
huya.py
27
huya.py
@ -4,6 +4,30 @@
|
||||
|
||||
import requests
|
||||
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):
|
||||
@ -20,7 +44,8 @@ def get_real_url(room_id):
|
||||
if 'replay' in liveLineUrl:
|
||||
return '直播录像:' + liveLineUrl
|
||||
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:
|
||||
real_url = '未开播或直播间不存在'
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user