抖音插件代码优化
This commit is contained in:
@@ -62,7 +62,7 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
|
||||
# 保存上下文对象
|
||||
self.event_system = context.get("event_system")
|
||||
self.message_util:MessageUtil = context.get("message_util")
|
||||
self.message_util: MessageUtil = context.get("message_util")
|
||||
self.gbm = context.get("gbm")
|
||||
|
||||
# 从配置中获取参数
|
||||
@@ -115,7 +115,7 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
|
||||
original_url = self._clean_url(match.group(0))
|
||||
self.LOG.info(f"发现抖音链接: {original_url}")
|
||||
|
||||
|
||||
# 解析抖音视频
|
||||
video_info = self._parse_douyin(original_url)
|
||||
if not video_info:
|
||||
@@ -144,10 +144,10 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
else:
|
||||
# 发送卡片
|
||||
self.message_util.send_rich_text(
|
||||
"BOT-PC直接查看",
|
||||
"gh_11",
|
||||
title[:30],
|
||||
f"PC直接查看-{title[:20]} - {author[:10]}",
|
||||
"BOT-PC直接查看",
|
||||
"gh_11",
|
||||
title[:30],
|
||||
f"PC直接查看-{title[:20]} - {author[:10]}",
|
||||
video_url,
|
||||
cover,
|
||||
(roomid if roomid else sender)
|
||||
@@ -173,7 +173,8 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
"""清理响应数据"""
|
||||
if not data:
|
||||
return data
|
||||
data['cover'] = "https://is1-ssl.mzstatic.com/image/thumb/Purple221/v4/7c/49/e1/7c49e1af-ce92-d1c4-9a93-0a316e47ba94/AppIcon_TikTok-0-0-1x_U007epad-0-1-0-0-85-220.png/512x512bb.jpg"
|
||||
data[
|
||||
'cover'] = "https://is1-ssl.mzstatic.com/image/thumb/Purple221/v4/7c/49/e1/7c49e1af-ce92-d1c4-9a93-0a316e47ba94/AppIcon_TikTok-0-0-1x_U007epad-0-1-0-0-85-220.png/512x512bb.jpg"
|
||||
return data
|
||||
|
||||
def _get_real_video_url(self, video_url: str) -> str:
|
||||
@@ -313,4 +314,4 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
self.LOG.error(f"文件写入失败: {e}")
|
||||
except Exception as e:
|
||||
self.LOG.error(f"发生未知错误: {e}")
|
||||
return None
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user