23 lines
619 B
Python
23 lines
619 B
Python
import subprocess
|
|||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from nonebot_plugin_alconna import UniMessage
|
||
|
|
|
||
|
|
|
||
|
|
def local_video(path: str) -> UniMessage:
|
||
|
|
"""构造本地视频消息(覆盖 Media.__post_init__ 的 https 前缀规范化)"""
|
||
|
|
msg = UniMessage.video(url=path)
|
||
|
|
msg[0].url = path
|
||
|
|
return msg
|
||
|
|
|
||
|
|
|
||
|
|
def get_video_info(url: str) -> str:
|
||
|
|
res = subprocess.run(["you-get", "-i", url], capture_output=True, text=True)
|
||
|
|
return res.stdout
|
||
|
|
|
||
|
|
|
||
|
|
def download_video(url: str, filepath: Path, filename: str) -> None:
|
||
|
|
subprocess.run(
|
||
|
|
["you-get", "-o", str(filepath), "-O", filename, url], capture_output=True
|
||
|
|
)
|