From df29586b7d6f833d6faa6042e04366c64ba67ac8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 23 May 2024 01:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=95=B0=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B9=E6=B3=95=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 ++++--------- api/open_live.py | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 37b0d36..9c941b1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ ## 使用方法 -以下几种方式任选一种即可 +以下几种方式任选一种即可。**正式使用之前记得看[注意事项](https://github.com/xfgryujk/blivechat/wiki/%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%E5%92%8C%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)** + +推荐的方式:如果你需要使用插件、翻译等高级特性,则在本地使用;否则推荐直接通过公共服务器在线使用。因为本地使用时不会自动升级版本,有时候出了问题不能及时解决;但公共服务器会禁用部分高级特性,如果你有需要,只能本地使用了 ### 一、本地使用 @@ -39,16 +41,9 @@ 4. 用样式生成器生成样式,复制CSS 5. 在OBS中添加浏览器源,输入URL和自定义CSS -**注意事项:** - -* 本地使用时不要关闭blivechat.exe那个黑框,否则不能继续获取弹幕 -* 如果需要使用翻译功能,建议看[配置官方翻译接口教程](https://github.com/xfgryujk/blivechat/wiki/%E9%85%8D%E7%BD%AE%E5%AE%98%E6%96%B9%E7%BF%BB%E8%AF%91%E6%8E%A5%E5%8F%A3) - ### 二、公共服务器 -请优先在本地使用,因为公共服务器会禁用部分特性 - -* [公共服务器](http://chat.bilisc.com/) +直接用浏览器打开[公共服务器](http://chat.bilisc.com/),剩下的步骤和本地使用时是一样的 ### 三、源代码版(自建服务器或在Windows以外平台) diff --git a/api/open_live.py b/api/open_live.py index e989ef8..4b6ab50 100644 --- a/api/open_live.py +++ b/api/open_live.py @@ -84,7 +84,7 @@ async def request_open_live(url, body: dict, *, ignore_rate_limit=False) -> dict # 频率限制,防止触发B站风控被下架 if not _open_live_rate_limiter.try_decrease_token() and not ignore_rate_limit: - raise BusinessError({'code': 4009, 'message': '接口访问限制', 'request_id': '0', 'data': None}) + raise BusinessError({'code': 4009, 'message': 'BLC接口访问限制', 'request_id': '0', 'data': None}) body_bytes = json.dumps(body).encode('utf-8') headers = { @@ -115,7 +115,12 @@ async def request_open_live(url, body: dict, *, ignore_rate_limit=False) -> dict logger.exception('Request open live failed:') raise except BusinessError as e: - logger.warning('Request open live failed: %s', e) + msg = str(e) + if e.code == 7010: + # 新版本日志可以截断,避免日志太长了 + msg = msg[:30] + '...' + logger.warning('Request open live failed: %s', msg) + if e.code == 7007: _error_auth_code_cache[auth_code] = True raise @@ -128,6 +133,13 @@ async def _read_response(req_ctx_mgr: AsyncContextManager[aiohttp.ClientResponse data = await r.json() code = data['code'] if code != 0: + if code == 7010: + data['message'] += ( + ' 解决方法:https://github.com/xfgryujk/blivechat/wiki/%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%E5' + '%92%8C%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#%E6%8A%A5%E9%94%997010-%E8%B6%85%E8%BF%87%E4%B8%8' + 'A%E9%99%90%E5%90%8C%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E5%8D%95%E4%B8%AA%E7%9B%B4%E6%92%AD%' + 'E9%97%B4%E6%9C%80%E5%A4%9A%E5%90%8C%E6%97%B6%E6%89%93%E5%BC%805%E4%B8%AA' + ) raise BusinessError(data) return data except (aiohttp.ClientError, asyncio.TimeoutError) as e: @@ -142,7 +154,7 @@ def _validate_auth_code(auth_code): ): raise BusinessError({ 'code': 7007, - 'message': 'oi!oi!oi!你的身份码错误了!别再重试了!!!!!!!!!!', + 'message': 'CNM!你的身份码错误了!别再重试了!!!!!!!!!!', 'request_id': '0', 'data': None }) @@ -225,9 +237,13 @@ class _StartGameMixin(_OpenLiveHandlerBase): game_id = None code = self.res['code'] + msg = self.res['message'] + if code == 7010: + # 新版本日志可以截断,避免日志太长了 + msg = msg[:10] + '...' logger.info( 'client=%s room_id=%s start game res: %s %s, game_id=%s', self.request.remote_ip, room_id, - code, self.res['message'], game_id + code, msg, game_id ) if code == 7007: # 身份码错误