refactor(managers): 重构单例管理器实现并优化代码结构
feat(ws_pool): 新增 WebSocket 连接池实现 perf(json): 使用 orjson 替代标准 json 库提升性能 style: 清理未使用的导入和冗余代码 docs: 更新架构文档和开发规范 test: 添加 WebSocket 连接池测试用例 fix(plugins): 修复自动审批插件 API 调用参数格式
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import json
|
||||
import aiohttp
|
||||
from typing import Optional, Dict, Any, List
|
||||
|
||||
@@ -40,7 +39,7 @@ class DouyinParser(BaseParser):
|
||||
api_url = f"http://api.xhus.cn/api/douyin?url={url}"
|
||||
|
||||
session = self.get_session()
|
||||
async with session.get(api_url, headers=self.HEADERS, timeout=10) as response:
|
||||
async with session.get(api_url, headers=self.HEADERS, timeout=aiohttp.ClientTimeout(total=10)) as response:
|
||||
if response.status != 200:
|
||||
logger.error(f"[{self.name}] API请求失败,状态码: {response.status}")
|
||||
return None
|
||||
@@ -75,7 +74,7 @@ class DouyinParser(BaseParser):
|
||||
"music": data.get("music", {}),
|
||||
}
|
||||
|
||||
except (aiohttp.ClientError, KeyError, AttributeError, json.JSONDecodeError) as e:
|
||||
except (aiohttp.ClientError, KeyError, AttributeError, ValueError) as e:
|
||||
logger.error(f"[{self.name}] 解析抖音视频信息失败: {e}")
|
||||
logger.debug(f"失败的URL: {url}")
|
||||
except Exception as e:
|
||||
@@ -110,7 +109,7 @@ class DouyinParser(BaseParser):
|
||||
'Referer': 'https://www.douyin.com/'
|
||||
})
|
||||
|
||||
async with session.get(short_url, headers=mobile_headers, allow_redirects=True, timeout=10) as response:
|
||||
async with session.get(short_url, headers=mobile_headers, allow_redirects=True, timeout=aiohttp.ClientTimeout(total=10)) as response:
|
||||
redirected_url = str(response.url)
|
||||
|
||||
# 检查重定向后的URL是否包含视频ID
|
||||
|
||||
Reference in New Issue
Block a user