diff --git a/konabot/plugins/ytpgif/__init__.py b/konabot/plugins/ytpgif/__init__.py index 2be0a62..42c9354 100644 --- a/konabot/plugins/ytpgif/__init__.py +++ b/konabot/plugins/ytpgif/__init__.py @@ -2,6 +2,7 @@ from io import BytesIO from typing import Optional from PIL import Image +from loguru import logger from nonebot.adapters import Event as BaseEvent from nonebot.adapters import Bot as BaseBot from nonebot.plugin import PluginMetadata @@ -117,16 +118,17 @@ async def handle_ytpgif(event: BaseEvent, bot: BaseBot, speed: float = 1.0): try: n_frames = getattr(src_img, "n_frames", 1) is_animated = n_frames > 1 + logger.debug(f"收到的动图的运动状态:{is_animated} 帧数量:{n_frames}") except Exception: is_animated = False - n_frames = 1 + n_frames = 1 output_frames = [] output_durations_ms = [] if is_animated: # === 动图模式:截取正向 + 镜像两段 === - frames_with_duration = [] + frames_with_duration: list[tuple[Image.Image, float]] = [] palette = src_img.getpalette() for idx in range(n_frames): @@ -148,6 +150,7 @@ async def handle_ytpgif(event: BaseEvent, bot: BaseBot, speed: float = 1.0): try: resized_frame.putpalette(palette) except Exception: # noqa + logger.debug("色板应用失败") pass ms = frame.info.get("duration", int(BASE_SEGMENT_DURATION * 1000))