From e99dc7c5a32ca82518ee5e669734f045caf72c7f Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 4 Sep 2023 19:15:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=AA=E5=8F=98=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blivedm/clients/open_live.py | 16 ++++++++-------- open_live_sample.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/blivedm/clients/open_live.py b/blivedm/clients/open_live.py index 4f4c3fd..c7add0a 100644 --- a/blivedm/clients/open_live.py +++ b/blivedm/clients/open_live.py @@ -29,8 +29,8 @@ class OpenLiveClient(ws_base.WebSocketClientBase): 文档参考:https://open-live.bilibili.com/document/ - :param access_key: 在开放平台申请的access_key - :param access_secret: 在开放平台申请的access_secret + :param access_key_id: 在开放平台申请的access_key_id + :param access_key_secret: 在开放平台申请的access_key_secret :param app_id: 在开放平台创建的项目ID :param room_owner_auth_code: 主播身份码 :param session: cookie、连接池 @@ -40,8 +40,8 @@ class OpenLiveClient(ws_base.WebSocketClientBase): def __init__( self, - access_key: str, - access_secret: str, + access_key_id: str, + access_key_secret: str, app_id: int, room_owner_auth_code: str, *, @@ -51,8 +51,8 @@ class OpenLiveClient(ws_base.WebSocketClientBase): ): super().__init__(session, heartbeat_interval) - self._access_key = access_key - self._access_secret = access_secret + self._access_key_id = access_key_id + self._access_key_secret = access_key_secret self._app_id = app_id self._room_owner_auth_code = room_owner_auth_code self._game_heartbeat_interval = game_heartbeat_interval @@ -122,7 +122,7 @@ class OpenLiveClient(ws_base.WebSocketClientBase): def _request_open_live(self, url, body: dict): body_bytes = json.dumps(body).encode('utf-8') headers = { - 'x-bili-accesskeyid': self._access_key, + 'x-bili-accesskeyid': self._access_key_id, 'x-bili-content-md5': hashlib.md5(body_bytes).hexdigest(), 'x-bili-signature-method': 'HMAC-SHA256', 'x-bili-signature-nonce': str(random.randint(0, 999999999)), @@ -135,7 +135,7 @@ class OpenLiveClient(ws_base.WebSocketClientBase): for key, value in headers.items() ) signature = hmac.new( - self._access_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256 + self._access_key_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256 ).hexdigest() headers['Authorization'] = signature diff --git a/open_live_sample.py b/open_live_sample.py index f963af6..68b1782 100644 --- a/open_live_sample.py +++ b/open_live_sample.py @@ -6,8 +6,8 @@ import blivedm.models.open_live as open_models import blivedm.models.web as web_models # 在开放平台申请的开发者密钥 -ACCESS_KEY = '' -ACCESS_SECRET = '' +ACCESS_KEY_ID = '' +ACCESS_KEY_SECRET = '' # 在开放平台创建的项目ID APP_ID = 0 # 主播身份码 @@ -23,8 +23,8 @@ async def run_single_client(): 演示监听一个直播间 """ client = blivedm.OpenLiveClient( - access_key=ACCESS_KEY, - access_secret=ACCESS_SECRET, + access_key_id=ACCESS_KEY_ID, + access_key_secret=ACCESS_KEY_SECRET, app_id=APP_ID, room_owner_auth_code=ROOM_OWNER_AUTH_CODE, )