autocaption 支持视频信息

This commit is contained in:
xtaodada 2022-01-24 14:41:58 +08:00
parent 27927b480a
commit 6400de6136
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 16 additions and 3 deletions

View File

@ -2,7 +2,7 @@ from pagermaid import version
from pagermaid.listener import listener from pagermaid.listener import listener
from telethon.tl.custom.message import Message from telethon.tl.custom.message import Message
from telethon.tl.types import MessageMediaDocument, DocumentAttributeFilename, DocumentAttributeImageSize, \ from telethon.tl.types import MessageMediaDocument, DocumentAttributeFilename, DocumentAttributeImageSize, \
DocumentAttributeAudio DocumentAttributeAudio, DocumentAttributeSticker, DocumentAttributeVideo, DocumentAttributeAnimated
def unit_convert(byte): def unit_convert(byte):
@ -56,6 +56,19 @@ async def auto_caption_file(context: Message):
text += f"`音乐时长:{duration_convert(i.duration)}`\n" text += f"`音乐时长:{duration_convert(i.duration)}`\n"
else: else:
text += f"`语音时长:{duration_convert(i.duration)}`\n" text += f"`语音时长:{duration_convert(i.duration)}`\n"
# 视频时长、尺寸
if isinstance(i, DocumentAttributeVideo):
text += f"`视频尺寸:{i.w}x{i.h}`\n"
text += f"`视频时长:{duration_convert(i.duration)}`\n"
text += f"`应用内播放:{'' if i.supports_streaming else ''}`\n"
# 过滤○视频
if i.round_message:
return
# 过滤 sticker
if isinstance(i, DocumentAttributeSticker):
return
if isinstance(i, DocumentAttributeAnimated):
return
# 文件类型 # 文件类型
text += f"`文件类型:{context.media.document.mime_type}`\n" text += f"`文件类型:{context.media.document.mime_type}`\n"
# 文件大小 # 文件大小

View File

@ -852,10 +852,10 @@
}, },
{ {
"name": "autocaption", "name": "autocaption",
"version": "1.001", "version": "1.01",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "2.2 kb", "size": "2.83 kb",
"supported": true, "supported": true,
"des-short": "自动获取所发送文件的信息。", "des-short": "自动获取所发送文件的信息。",
"des": "自动获取所发送文件的信息。" "des": "自动获取所发送文件的信息。"