Skip to main content

NoneBot2 链接分享解析 Alconna 版, 通用媒体卡片渲染(PIL 实现), 支持 B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun/nga

Project description

logo

Nonebot2 链接分享自动解析插件 ✨

LICENSE pypi python uv ruff
pre-commit codecov qqgroup

[!IMPORTANT] 收藏项目,你将从 GitHub 上无延迟地接收所有发布通知~⭐️

starify

📖 介绍

平台 触发的消息形态 视频 图集 音频
B站 BV号/链接(包含短链,BV,av)/卡片/小程序 ✅​ ✅​ ✅​
抖音 链接(分享链接,兼容电脑端链接) ✅​ ✅​ ❌️
微博 链接(博文,视频,show) ✅​ ✅​ ❌️
小红书 链接(含短链)/卡片 ✅​ ✅​ ❌️
快手 链接(包含标准链接和短链) ✅​ ✅​ ❌️
acfun 链接 ✅​ ❌️ ❌️
youtube 链接(含短链) ✅​ ❌️ ✅​
tiktok 链接 ✅​ ❌️ ❌️
twitter 链接 ✅​ ✅​ ❌️

支持的链接,可参考 测试链接

🎨 效果图

插件默认启用 PIL 实现的通用媒体卡片渲染,效果图如下

💿 安装

[!Warning] 如果你已经在使用 nonebot-plugin-resolver[2],请在安装此插件前卸载

使用 nb-cli 安装/更新 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-parser --upgrade

使用 pypi 源更新

nb plugin install nonebot-plugin-parser --upgrade -i https://pypi.org/simple

安装仓库 dev 分支

uv pip install git+https://github.com/fllesser/nonebot-plugin-parser.git@dev
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
uv 使用 uv 安装
uv add nonebot-plugin-parser

安装仓库 dev 分支

uv add git+https://github.com/fllesser/nonebot-plugin-parser.git@master
pip
pip install --upgrade nonebot-plugin-parser
pdm
pdm add nonebot-plugin-parser
poetry
poetry add nonebot-plugin-parser

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_parser"]
使用 nbr 安装(使用 uv 管理依赖可用)

nbr 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2

nbr plugin install nonebot-plugin-parser

使用 pypi 源安装

nbr plugin install nonebot-plugin-parser -i "https://pypi.org/simple"

使用清华源安装

nbr plugin install nonebot-plugin-parser -i "https://pypi.tuna.tsinghua.edu.cn/simple"
安装必要组件 部分解析依赖于 ffmpeg

ubuntu/debian

sudo apt-get install ffmpeg

其他 linux 参考(原项目推荐): https://gitee.com/baihu433/ffmpeg

Windows 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c

⚙️ 配置

在 nonebot2 项目的.env文件中添加下表中的必填配置

配置项 必填 默认值 说明
NICKNAME [""] nonebot2 内置配置,可作为解析结果消息的前缀
API_TIMEOUT 30.0 nonebot2 内置配置,若服务器上传带宽太低,建议调高,防止超时
parser_bili_ck "" B 站 cookie, 必须含有 SESSDATA 项,可附加 B 站 AI 总结功能, 如果需要长期使用此凭据则不应该在浏览器登录账户导致 cookie 被刷新,建议注册个小号获取, 也可以配置 ac_time_value 项,用于凭据的自动刷新,获取方式
parser_bili_video_codes '["avc", "av01", "hev"]' 允许的 B 站视频编码,越靠前的编码优先级越高,可选 "avc"(H.264,体积较大), "hev"(HEVC), "av01"(AV1), 后两项在不同设备可能有兼容性问题,如需完全避免,可只填一项,如 '["avc"]'
parser_ytb_ck "" Youtube cookie, Youtube 视频因人机检测下载失败,需填
parser_proxy None 仅作用于 youtube, tiktok 解析,推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置)
parser_need_upload False 音频解析,是否需要上传群文件
parser_use_base64 False 视频,图片,音频是否使用 base64 发送,注意:编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃,因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置
parser_duration_maximum 480 视频最大解析时长,单位:
parser_max_size 90 音视频下载最大文件大小,单位 MB,超过该配置将阻断下载
parser_disabled_platforms [] 全局禁止的解析,示例 parser_disabled_platforms=["bilibili", "douyin"] 表示禁止了哔哩哔哩和抖, 请根据自己需求填写["bilibili", "douyin", "kuaishou", "twitter", "youtube", "acfun", "tiktok", "weibo", "xiaohongshu"]
parser_render_type "common" 渲染器类型,可选 "default"(无图片渲染), "common"(PIL 通用图片渲染), "htmlkit"(htmlkit, 暂不可用)
parser_append_url False 是否在解析结果中附加原始URL
parser_custom_font None 自定义渲染字体,配置字体文件名,并将字体文件放置于 localstore 生成的插件 data 目录下(如 ./data/nonebot_plugin_parser/)
parser_need_forward_contents True 是否需要转发媒体内容(超过 4 项时始终使用合并转发)

🎉 使用

指令表

指令 权限 需要@ 范围 说明
开启解析 SUPERUSER/OWNER/ADMIN 群聊 开启解析
关闭解析 SUPERUSER/OWNER/ADMIN 群聊 关闭解析

推荐的字体

致谢

nonebot-plugin-resolver parse-video-py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_parser-2.0.13.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_parser-2.0.13-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_parser-2.0.13.tar.gz.

File metadata

  • Download URL: nonebot_plugin_parser-2.0.13.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nonebot_plugin_parser-2.0.13.tar.gz
Algorithm Hash digest
SHA256 f197d0a7f6bce4e4018b9e9f642df89ca98efb83ad783ab0d2f6b19f9027b883
MD5 d97fd500bc4f82fc68173cc6a26148c6
BLAKE2b-256 04555c52f81203b7f756db35e413f1e7dee2de92c8054c43097796cf22242b86

See more details on using hashes here.

File details

Details for the file nonebot_plugin_parser-2.0.13-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_parser-2.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 57314661ebd2600f32cc8efa6231a9587bae901cedb8252ff6ac5c0c27e45e34
MD5 f7b17dcc27eaf15166922a224342fd99
BLAKE2b-256 ae452e54715ab60b23ddfa2911779d177d04c1689b9418020e9583ab29fe5c78

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page