mirror of
https://github.com/xfgryujk/blivedm.git
synced 2024-12-26 12:50:13 +08:00
修复开放平台接口启用的判断逻辑
This commit is contained in:
parent
ad1fd62f29
commit
20867a2135
@ -104,6 +104,7 @@ class BLiveClient:
|
||||
heartbeat_interval=30,
|
||||
ssl: Union[bool, ssl_.SSLContext] = True,
|
||||
|
||||
use_open_live: bool = False,
|
||||
open_live_app_id: Optional[int] = None,
|
||||
open_live_access_key: Optional[str] = None,
|
||||
open_live_access_secret: Optional[str] = None,
|
||||
@ -150,10 +151,11 @@ class BLiveClient:
|
||||
self._heartbeat_timer_handle: Optional[asyncio.TimerHandle] = None
|
||||
"""发心跳包定时器的handle"""
|
||||
|
||||
self._open_live_client = None
|
||||
self._host_server_auth_body: Dict = None
|
||||
"""开放平台的完整鉴权body"""
|
||||
|
||||
if open_live_app_id and open_live_access_key and open_live_access_secret and open_live_code:
|
||||
if use_open_live:
|
||||
self._open_live_client = OpenLiveClient(open_live_app_id, open_live_access_key, open_live_access_secret, self._session, self._ssl)
|
||||
self._open_live_auth_code = open_live_code
|
||||
|
||||
|
@ -149,7 +149,7 @@ class OpenLiveClient:
|
||||
return False
|
||||
|
||||
try:
|
||||
params = f'{{"app_id":"{self.app_id}","game_id":{self._game_id}}}'
|
||||
params = f'{{"app_id":{self.app_id},"game_id":{self._game_id}}}'
|
||||
headers = self._sign_request_header(params)
|
||||
async with self._session.post(
|
||||
OPEN_LIVE_END_URL, headers=headers, data=params, ssl=self._ssl
|
||||
@ -175,7 +175,8 @@ class OpenLiveClient:
|
||||
return False
|
||||
|
||||
try:
|
||||
params = f'{{""game_id":{self._game_id}}}'
|
||||
params = f'{{"game_id":{self._game_id}}}'
|
||||
print(params)
|
||||
headers = self._sign_request_header(params)
|
||||
async with self._session.post(
|
||||
OPEN_LIVE_HEARTBEAT_URL, headers=headers, data=params, ssl=self._ssl
|
||||
|
@ -19,14 +19,14 @@ async def main():
|
||||
await run_start()
|
||||
|
||||
async def run_start():
|
||||
client = blivedm.BLiveClient(open_live_app_id=APP_ID, open_live_access_key=ACCESS_KEY, open_live_access_secret=ACCESS_KEY_SECRET, open_live_code=TEST_AUTH_CODE, ssl=True)
|
||||
client = blivedm.BLiveClient(use_open_live=True, open_live_app_id=APP_ID, open_live_access_key=ACCESS_KEY, open_live_access_secret=ACCESS_KEY_SECRET, open_live_code=TEST_AUTH_CODE, ssl=True)
|
||||
handler = OpenLiveHandlerInterface()
|
||||
client.add_handler(handler)
|
||||
|
||||
client.start()
|
||||
try:
|
||||
# 演示60秒后停止
|
||||
await asyncio.sleep(60)
|
||||
await asyncio.sleep(600)
|
||||
client.stop()
|
||||
|
||||
await client.join()
|
||||
|
Loading…
Reference in New Issue
Block a user