Per docs/plugin-audit-report.md (plugins normalized to Trigger(handlers) → Service(services) → Model(repository/models) + utils): - Split monolithic __init__.py into handlers/services/utils across dailywife, deer_pipe, dice, galgame_card, helldivers_tools, huoziyinshua, learning_chat, makeaquote, mc_server_status, ncm_saying, picfinder_take, picstatus, random_jm_code, regif, steam_info, video_analysis, group_tools - Move static assets under res/: deer_pipe font/img, makeaquote font, helldivers img/templates, huoziyinshua HuoZiYinShua - Add config.py + register_config_items to ncm_saying, random_jm_code, group_tools; learning_chat unified config bridge - Remove deprecated: voice_trans plugin, bf_bot/test.py, dead code in dailywife/deer_pipe, empty dirs, debug scripts under helldivers temp - Disable brash_general_supercredits_tools (stub comment only) - bot.py: optional stdout/stderr redirect to log file for Web log viewer, force ANSI colorize on non-TTY sinks - Move runtime data (jm_code.json) out of plugin dir into hexi/data - Docs: plugin-audit-report.md; README reflects removed plugins Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
"""通用平台视频解析编排层 — B站 / YouTube / Twitter 等"""
|
|
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from nonebot import logger
|
|
from nonebot_plugin_alconna import UniMessage
|
|
|
|
from ..services.fetchers.video_downloader import download_video
|
|
from .sender import PendingMedia, _as_paths
|
|
|
|
|
|
async def handle_universal(
|
|
url: str,
|
|
is_private: bool,
|
|
plan: str | None = None,
|
|
) -> tuple[Optional[PendingMedia], Optional[str]]:
|
|
"""
|
|
下载通用平台视频 → 打包待发送媒体(上传/发送由 sender 多级处理)
|
|
|
|
Returns:
|
|
(PendingMedia, public_url) — None 表示下载失败
|
|
"""
|
|
video_file = await download_video(url)
|
|
if not video_file:
|
|
await UniMessage.text("视频下载失败。").send()
|
|
return None, None
|
|
|
|
logger.info(f"文件路径:{video_file}")
|
|
|
|
return (
|
|
PendingMedia(
|
|
files=_as_paths(video_file),
|
|
image_post=False,
|
|
is_private=is_private,
|
|
plan=plan,
|
|
title="title",
|
|
),
|
|
None,
|
|
)
|