{"id":28943996,"url":"https://github.com/fllesser/nonebot-plugin-parser","last_synced_at":"2026-03-17T07:29:33.871Z","repository":{"id":265657851,"uuid":"896429369","full_name":"fllesser/nonebot-plugin-parser","owner":"fllesser","description":"社交媒体分享链接解析插件","archived":false,"fork":false,"pushed_at":"2026-02-16T04:02:48.000Z","size":8383,"stargazers_count":144,"open_issues_count":8,"forks_count":21,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-17T20:35:34.175Z","etag":null,"topics":["nonebot-plugin","nonebot2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fllesser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-30T10:43:02.000Z","updated_at":"2026-02-17T12:56:24.000Z","dependencies_parsed_at":"2025-01-16T08:36:58.852Z","dependency_job_id":"b479101f-8282-4c04-9c06-f0a8369b9538","html_url":"https://github.com/fllesser/nonebot-plugin-parser","commit_stats":null,"previous_names":["fllesser/nonebot-plugin-resolver2","fllesser/nonebot-plugin-parser"],"tags_count":143,"template":false,"template_full_name":"A-kirami/nonebot-plugin-template","purl":"pkg:github/fllesser/nonebot-plugin-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fllesser%2Fnonebot-plugin-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fllesser%2Fnonebot-plugin-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fllesser%2Fnonebot-plugin-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fllesser%2Fnonebot-plugin-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fllesser","download_url":"https://codeload.github.com/fllesser/nonebot-plugin-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fllesser%2Fnonebot-plugin-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29681468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T12:30:22.644Z","status":"ssl_error","status_checked_at":"2026-02-21T12:29:55.402Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nonebot-plugin","nonebot2"],"created_at":"2025-06-23T05:16:15.542Z","updated_at":"2026-03-17T07:29:33.858Z","avatar_url":"https://github.com/fllesser.png","language":"Python","readme":"\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://v2.nonebot.dev/store\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-template/refs/heads/resource/.docs/NoneBotPlugin.svg\" width=\"310\" alt=\"logo\"\u003e\n\u003c/a\u003e\n\n## ✨ [Nonebot2](https://github.com/nonebot/nonebot2) 链接分享自动解析插件 ✨\n\n[![LICENSE](https://img.shields.io/github/license/fllesser/nonebot-plugin-parser.svg)](./LICENSE)\n[![pypi](https://img.shields.io/pypi/v/nonebot-plugin-parser.svg)](https://pypi.python.org/pypi/nonebot-plugin-parser)\n[![python](https://img.shields.io/badge/python-3.10|3.11|3.12|3.13|3.14-blue.svg)](https://python.org)\n[![uv](https://img.shields.io/badge/package%20manager-uv-black?style=flat-square\u0026logo=uv)](https://github.com/astral-sh/uv)\n[![ruff](https://img.shields.io/badge/code%20style-ruff-black?style=flat-square\u0026logo=ruff)](https://github.com/astral-sh/ruff)\n\u003cbr/\u003e\n[![pre-commit](https://results.pre-commit.ci/badge/github/fllesser/nonebot-plugin-parser/master.svg)](https://results.pre-commit.ci/latest/github/fllesser/nonebot-plugin-parser/master)\n[![codecov](https://codecov.io/gh/fllesser/nonebot-plugin-parser/graph/badge.svg?token=VCS8IHSO7U)](https://codecov.io/gh/fllesser/nonebot-plugin-parser)\n[![qqgroup](https://img.shields.io/badge/QQ%E7%BE%A4-820082006-orange?style=flat-square)](https://qm.qq.com/q/y4T4CjHimc)\n\n\u003c/div\u003e\n\n\u003e [!IMPORTANT] \n\u003e **收藏项目**，你将从 GitHub 上无延迟地接收所有发布通知～ ⭐️\n\n\u003cimg width=\"100%\" src=\"https://starify.komoridevs.icu/api/starify?owner=fllesser\u0026repo=nonebot-plugin-parser\" alt=\"starify\" /\u003e\n\n## 📖 介绍\n\n| 平台    | 触发的消息形态                    | 视频 | 图集 | 音频 |\n| ------- | --------------------------------- | ---- | ---- | ---- |\n| B 站    | av 号/BV 号/链接/短链/卡片/小程序 | ✅​  | ✅​  | ✅​  |\n| 抖音    | 链接(分享链接，兼容电脑端链接)    | ✅​  | ✅​  | ❌️  |\n| 微博    | 链接(博文，视频，show, 文章)      | ✅​  | ✅​  | ❌️  |\n| 小红书  | 链接(含短链)/卡片                 | ✅​  | ✅​  | ❌️  |\n| 快手    | 链接(包含标准链接和短链)          | ✅​  | ✅​  | ❌️  |\n| acfun   | 链接                              | ✅​  | ❌️  | ❌️  |\n| youtube | 链接(含短链)                      | ✅​  | ❌️  | ✅​  |\n| tiktok  | 链接                              | ✅​  | ❌️  | ❌️  |\n| twitter | 链接                              | ✅​  | ✅​  | ❌️  |\n\n支持的链接，可参考 [测试链接](https://github.com/fllesser/nonebot-plugin-parser/blob/master/tests/others/test_urls.md)\n\n## 🎨 效果图\n\n插件默认启用 PIL 实现的通用媒体卡片渲染，效果图如下\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-parser/refs/heads/resources/resources/renderdamine/video.png\" width=\"160\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-parser/refs/heads/resources/resources/renderdamine/9_pic.png\" width=\"160\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-parser/refs/heads/resources/resources/renderdamine/4_pic.png\" width=\"160\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-parser/refs/heads/resources/resources/renderdamine/repost_video.png\" width=\"160\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/fllesser/nonebot-plugin-parser/refs/heads/resources/resources/renderdamine/repost_2_pic.png\" width=\"160\" /\u003e\n\n\u003c/div\u003e\n\n## 💿 安装\n\n\u003e [!Warning] \n\u003e **如果你已经在使用 nonebot-plugin-resolver[2]，请在安装此插件前卸载**\n\n\u003cdetails\u003e\n\u003csummary\u003e使用 nb-cli 安装/更新\u003c/summary\u003e\n在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装\n\n    nb plugin install nonebot-plugin-parser --upgrade\n\n使用 pypi 源更新\n\n    nb plugin install nonebot-plugin-parser --upgrade -i https://pypi.org/simple\n\n安装仓库 dev 分支\n\n    uv pip install git+https://github.com/fllesser/nonebot-plugin-parser.git@dev\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e使用包管理器安装\u003c/summary\u003e\n在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令\n\u003cdetails\u003e\n\u003csummary\u003euv\u003c/summary\u003e\n使用 uv 安装\n\n    uv add nonebot-plugin-parser\n\n安装仓库 dev 分支\n\n    uv add git+https://github.com/fllesser/nonebot-plugin-parser.git@master\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003epip\u003c/summary\u003e\n\n    pip install --upgrade nonebot-plugin-parser\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003epdm\u003c/summary\u003e\n\n    pdm add nonebot-plugin-parser\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003epoetry\u003c/summary\u003e\n\n    poetry add nonebot-plugin-parser\n\n\u003c/details\u003e\n\n打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入\n\n    plugins = [\"nonebot_plugin_parser\"]\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e使用 nbr 安装(使用 uv 管理依赖可用)\u003c/summary\u003e\n\n[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli，可以方便地管理 nonebot2\n\n    nbr plugin install nonebot-plugin-parser\n\n使用 **pypi** 源安装\n\n    nbr plugin install nonebot-plugin-parser -i \"https://pypi.org/simple\"\n\n使用**清华源**安装\n\n    nbr plugin install nonebot-plugin-parser -i \"https://pypi.tuna.tsinghua.edu.cn/simple\"\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e安装可选依赖\u003c/summary\u003e\n\n`ytdlp`, 用于解析 `youtube` 和 `tiktok` 视频\n\n    uv add \"nonebot-plugin-parser[ytdlp]\"\n\n[emosvg](https://github.com/fllesser/emosvg) 用于渲染 `emoji` 表情, 基于 `cairo` 和 `svg` 实现，`win/mac` 用户，请确保自己会配置 `cairo`, 插件默认使用的依赖于网络的 `apilmoji`，已缓存的 `emoji` 渲染速度略快于 `emosvg`\n\n    uv add \"nonebot-plugin-parser[emosvg]\"\n\n`htmlkit`, 无 js 渲染 `html`, 插件目前还没有供 `htmlkit` 使用的模版, 因此可忽略此依赖\n\n    uv add \"nonebot-plugin-parser[htmlkit]\"\n\n`htmlrender`, 使用 `playwright` 渲染 `html`, 插件自 `v2.5.0` 起已正式支持\n\n    uv add \"nonebot-plugin-parser[htmlrender]\"\n\n现版本推荐组合\n\n    uv add \"nonebot-plugin-parser[ytdlp,emosvg]\"\n\n`all` 顾名思义，安装所有可选依赖\n\n    uv add \"nonebot-plugin-parser[all]\"\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e安装必要组件\u003c/summary\u003e\n\n部分解析依赖 `ffmpeg`\n\n`ubuntu/debian`\n\n    sudo apt-get install ffmpeg\n\n其他 `Linux` 参考(原项目推荐): https://gitee.com/baihu433/ffmpeg\n\n`Windows` 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c\n\n`yt-dlp` 自 `2025.11.12` 起要求用户安装外部 `JavaScript Runtime`，参考 https://github.com/yt-dlp/yt-dlp/releases/tag/2025.11.12, 推荐安装 [Deno](https://deno.com)\n\n`macOS / Linux`\n\n    curl -fsSL https://deno.land/install.sh | sh\n\n`windows`\n\n    irm https://deno.land/install.ps1 | iex\n\n\u003c/details\u003e\n\n## ⚙️ 配置\n\n\u003cdetails\u003e\n\u003csummary\u003e配置项\u003c/summary\u003e\n\n```bash\n# [可选] nonebot2 内置配置，若服务器上传带宽太低，建议调高，防止超时\nAPI_TIMEOUT=30.0\n\n# [可选] B 站 cookie, 必须含有 SESSDATA 项，可附加 B 站 AI 总结功能\n# 如果需要长期使用此凭据则不应该在浏览器登录账户导致 cookie 被刷新，建议注册个小号获取\n# 各项获取方式 https://nemo2011.github.io/bilibili-api/#/get-credential\n# ac_time_value 相对特殊，仅用于刷新 Cookies\n# B站网页打开开发者工具，进入控制台，输入 window.localStorage.ac_time_value 即可获取其值。\nparser_bili_ck=\"SESSDATA=xxxxxxxxxx;ac_time_value=131231241231241\"\n\n# [可选] 允许的 B 站视频编码，越靠前的编码优先级越高\n# 可选 \"avc\"(H.264，体积较大), \"hev\"(HEVC), \"av01\"(AV1)\n# 后两项在不同设备可能有兼容性问题，如需完全避免，可只填一项，如 '[\"avc\"]'\nparser_bili_video_codes='[\"avc\", \"av01\", \"hev\"]'\n\n# [可选] B 站视频清晰度\n# 360p(16), 480p(32), 720p(64), 1080p(80), 1080p+(112), 1080p_60(116), 4k(120)\nparser_bili_video_quality=80\n\n# [可选] 小红书 Cookie, 部分链接解析有水印，可填\nparser_xhs_ck=\"\"\n\n# [可选] Youtube Cookie, Youtube 视频因人机检测下载失败，需填\nparser_ytb_ck=\"\"\n\n# [可选] 代理, 仅作用于 youtube, tiktok 解析\n# 推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置)\nparser_proxy=None\n\n# [可选] 音频解析，是否需要上传群文件\nparser_need_upload=False\n\n# [可选] 视频，图片，音频是否使用 base64 发送\n# 注意：编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃\n# 因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置\nparser_use_base64=False\n\n# [可选] 视频最大解析时长，单位：秒\nparser_duration_maximum=480\n\n# [可选] 音视频下载最大文件大小，单位 MB，超过该配置将阻断下载\nparser_max_size=90\n\n# [可选] 全局禁止的解析\n# 示例 parser_disabled_platforms=[\"bilibili\", \"douyin\"] 表示禁止了哔哩哔哩和抖音\n# 可选值: [\"bilibili\", \"douyin\", \"kuaishou\", \"twitter\", \"youtube\", \"acfun\", \"tiktok\", \"weibo\", \"xiaohongshu\"]\nparser_disabled_platforms='[\"twitter\"]'\n\n# [可选] 渲染器类型\n# 可选 \"default\"(无图片渲染), \"common\"(PIL 通用图片渲染), \"htmlrender\"(htmlrender), \"htmlkit\"(htmlkit, 暂不可用)\nparser_render_type=\"common\"\n\n# [可选] 是否在解析结果中附加原始URL\nparser_append_url=False\n\n# [可选] 自定义渲染字体\n# 配置字体文件名，并将字体文件放置于 localstore 生成的插件 config 目录下\n# 例如: ./config/nonebot_plugin_parser/\nparser_custom_font=\"LXGWZhenKaiGB-Regular.ttf\"\n\n# [可选] 是否需要转发媒体内容(超过 4 项时始终使用合并转发)\nparser_need_forward_contents=True\n\n# [可选] emoji 渲染 CDN\n# 例如 ELK_SH_CDN = \"https://emojicdn.elk.sh\", MQRIO_DEV_CDN = \"https://emoji-cdn.mqrio.dev\"\nparser_emoji_cdn=\"https://emojicdn.elk.sh\"\n\n# [可选] emoji 渲染样式 \"apple\", \"google\", \"twitter\", \"facebook\"(默认)\nparser_emoji_style=\"facebook\"\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e推荐的字体\u003c/summary\u003e\n\n- [LXGW ZhenKai / 霞鹜臻楷](https://github.com/lxgw/LxgwZhenKai) 效果图使用字体\n- [LXGW Neo XiHei / 霞鹜新晰黑](https://github.com/lxgw/LxgwNeoXiHei)\n- [LXGW Neo ZhiSong / 霞鹜新致宋 / 霞鶩新緻宋](https://github.com/lxgw/LxgwNeoZhiSong)\n\u003c/details\u003e\n\n## 🎉 使用\n\n|   指令   |         权限          | 需要@ | 范围 |       说明        |\n| :------: | :-------------------: | :---: | :--: | :---------------: |\n| 开启解析 | SUPERUSER/OWNER/ADMIN |  是   | 群聊 |     开启解析      |\n| 关闭解析 | SUPERUSER/OWNER/ADMIN |  是   | 群聊 |     关闭解析      |\n|    bm    |           -           |  否   | 群聊 |   下载 B 站音频   |\n|    ym    |           -           |  否   | 群聊 | 下载 youtube 音频 |\n|  blogin  |       SUPERUSER       |  否   | 私聊 | 扫码获取 B 站凭证 |\n\n## 🧩 扩展\n\n\u003e [!IMPORTANT]\n\u003e 插件自 `v2.2.0` 版本开始支持自定义解析器，通过继承 `BaseParser` 类并实现 `platform`, `handle` 即可\n\n\u003cdetails\u003e\n\u003csummary\u003e完整示例\u003c/summary\u003e\n\n```python\nfrom re import Match\nfrom typing import ClassVar\n\nfrom httpx import AsyncClient\nfrom nonebot import require\n\nrequire(\"nonebot_plugin_parser\")\nfrom nonebot_plugin_parser.parsers import BaseParser, Platform, handle\n\nclass ExampleParser(BaseParser):\n    \"\"\"示例视频网站解析器\"\"\"\n\n    platform: ClassVar[Platform] = Platform(name=\"example\", display_name=\"示例网站\")\n\n    @handle(\"ex.short\", r\"ex\\.short/\\w+)\")\n    async def _parse_short_link(self, searched: Match[str]):\n        \"\"\"解析短链\"\"\"\n        url = f\"https://{searched.group(0)}\"\n        # 重定向再解析，请确保重定向链接的 handle 存在\n        # 比如 url 重定向到 example.com/... 就会调用 _parse 解析\n        return await self.parse_with_redirect(url)\n\n    @handle(\"example.com\", r\"example\\.com/video/(?P\u003cvideo_id\u003e\\w+)\")\n    @handle(\"exam.ple\", r\"exam\\.ple/(?P\u003cvideo_id\u003e\\w+)\")\n    async def _parse(self, searched: Match[str]):\n        # 1. 提取视频 ID\n        video_id = searched.group(\"video_id\")\n\n        # 2. 请求 API 获取视频信息\n        async with AsyncClient(headers=self.headers, timeout=self.timeout) as client:\n            resp = await client.get(f\"https://api.example.com/video/{video_id}\")\n            resp.raise_for_status()\n            data = resp.json()\n\n        # 3. 提取数据\n        title = data[\"title\"]\n        author_name = data[\"author\"][\"name\"]\n        avatar_url = data[\"author\"][\"avatar\"]\n        video_url = data[\"video_url\"]\n        cover_url = data[\"cover_url\"]\n        duration = data[\"duration\"]\n        timestamp = data[\"publish_time\"]\n        description = data.get(\"description\", \"\")\n\n        # 4. 视频内容\n        author = self.create_author(author_name, avatar_url)\n        video = self.create_video_content(video_url, cover_url, duration)\n\n        # 5. 图集内容\n        image_urls = data.get(\"images\")\n        images = self.create_image_contents(image_urls)\n\n        # 6. 返回解析结果\n        return self.result(\n            title=title,\n            text=description,\n            author=author,\n            contents=[video, *images],\n            timestamp=timestamp,\n            url=f\"https://example.com/video/{video_id}\",\n        )\n\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e辅助函数\u003c/summary\u003e\n\n\u003e 构建作者信息\n\n```python\nauthor = self.create_author(\n    name=\"作者名\",\n    avatar_url=\"https://example.com/avatar.jpg\",   # 可选，会自动下载\n    description=\"个性签名\"                          # 可选\n)\n```\n\n\u003e 构建视频内容\n\n```python\n# 方式1：传入 URL，自动下载\nvideo = self.create_video_content(\n    url_or_task=\"https://example.com/video.mp4\",\n    cover_url=\"https://example.com/cover.jpg\",  # 可选\n    duration=120.5                               # 可选，单位：秒\n)\n\n# 方式2：传入已创建的下载任务\nfrom nonebot_plugin_parser.download import DOWNLOADER\nvideo_task = DOWNLOADER.download_video(url, ext_headers=self.headers)\nvideo = self.create_video_content(\n    url_or_task=video_task,\n    cover_url=cover_url,\n    duration=duration\n)\n```\n\n\u003e 构建图集内容\n\n```python\n# 并发下载图集内容\nimages = self.create_image_contents([\n    \"https://example.com/img1.jpg\",\n    \"https://example.com/img2.jpg\",\n])\n```\n\n\u003e 创建动图内容（GIF)，平台一般只提供视频（后续插件会做自动转为 gif 的处理)\n\n```python\ndynamics = self.create_dynamic_contents([\n    \"https://example.com/dynamic1.mp4\",\n    \"https://example.com/dynamic2.mp4\",\n])\n```\n\n\u003e 重定向 url\n\n```python\nreal_url = await self.get_redirect_url(\n    url=\"https://short.url/abc\",\n    headers=self.headers  # 可选\n)\n```\n\n\u003c/details\u003e\n\n## 🌟 星星\n\n[![Star History Chart](https://api.star-history.com/svg?repos=fllesser/nonebot-plugin-parser\u0026type=date\u0026legend=top-left)](https://www.star-history.com/#fllesser/nonebot-plugin-parser\u0026type=date\u0026legend=top-left)\n\n## 🎉 致谢\n\n[nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver)\n[parse-video-py](https://github.com/wujunwei928/parse-video-py)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffllesser%2Fnonebot-plugin-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffllesser%2Fnonebot-plugin-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffllesser%2Fnonebot-plugin-parser/lists"}