nonebot-plugin-parser 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. nonebot_plugin_parser-2.0.0/PKG-INFO +166 -0
  2. nonebot_plugin_parser-2.0.0/README.md +136 -0
  3. nonebot_plugin_parser-2.0.0/pyproject.toml +196 -0
  4. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/__init__.py +46 -0
  5. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/config.py +125 -0
  6. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/constants.py +22 -0
  7. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/download/__init__.py +217 -0
  8. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/download/task.py +18 -0
  9. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/download/ytdlp.py +140 -0
  10. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/exception.py +20 -0
  11. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/helper.py +134 -0
  12. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/matchers/__init__.py +107 -0
  13. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/matchers/filter.py +73 -0
  14. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/matchers/preprocess.py +208 -0
  15. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/__init__.py +17 -0
  16. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/acfun.py +170 -0
  17. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/base.py +128 -0
  18. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/bilibili/__init__.py +460 -0
  19. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/bilibili/opus.py +0 -0
  20. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/bilibili/video.py +127 -0
  21. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/cookie.py +58 -0
  22. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/data.py +267 -0
  23. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/douyin/__init__.py +118 -0
  24. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/douyin/slides.py +75 -0
  25. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/douyin/video.py +109 -0
  26. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/kuaishou.py +146 -0
  27. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/nga.py +190 -0
  28. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/tiktok.py +48 -0
  29. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/twitter.py +109 -0
  30. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/weibo.py +323 -0
  31. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/xiaohongshu.py +155 -0
  32. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/parsers/youtube.py +153 -0
  33. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/__init__.py +43 -0
  34. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/base.py +54 -0
  35. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/common.py +404 -0
  36. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/default.py +33 -0
  37. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/fonts/HYSongYunLangHeiW-1.ttf +0 -0
  38. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/templates/weibo.html.jinja +425 -0
  39. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/renders/weibo.py +28 -0
  40. nonebot_plugin_parser-2.0.0/src/nonebot_plugin_parser/utils.py +222 -0
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.3
2
+ Name: nonebot-plugin-parser
3
+ Version: 2.0.0
4
+ Summary: NoneBot2 链接分享解析器自动解析, BV号/链接/小程序/卡片 | B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun
5
+ Keywords: nonebot,nonebot2,video,bilibili,youtube,tiktok,twitter,kuaishou,acfun,weibo,xiaohongshu,nga,douyin
6
+ Author: fllesser
7
+ Author-email: fllesser <fllessive@gmail.com>
8
+ Requires-Dist: msgspec>=0.19.0,<1.0.0
9
+ Requires-Dist: httpx>=0.27.2,<1.0.0
10
+ Requires-Dist: tqdm>=4.67.1,<5.0.0
11
+ Requires-Dist: aiofiles>=24.1.0
12
+ Requires-Dist: pillow>=11.0.0
13
+ Requires-Dist: curl-cffi>=0.13.0,<1.0.0
14
+ Requires-Dist: bilibili-api-python>=17.3.0,<18.0.0
15
+ Requires-Dist: beautifulsoup4>=4.12.0,<5.0.0
16
+ Requires-Dist: yt-dlp>=2025.9.26
17
+ Requires-Dist: nonebot2>=2.4.3,<3.0.0
18
+ Requires-Dist: nonebot-plugin-localstore>=0.7.4,<1.0.0
19
+ Requires-Dist: nonebot-plugin-apscheduler>=0.5.0,<1.0.0
20
+ Requires-Dist: nonebot-plugin-alconna>=0.59.4
21
+ Requires-Dist: nonebot-plugin-uninfo>=0.9.0
22
+ Requires-Dist: nonebot-plugin-htmlkit>=0.1.0rc1 ; extra == 'htmlkit'
23
+ Requires-Dist: jinja2>=3.1.6 ; extra == 'htmlkit'
24
+ Requires-Python: >=3.10
25
+ Project-URL: IssueTracker, https://github.com/fllesser/nonebot-plugin-parser/issues
26
+ Project-URL: Release, https://github.com/fllesser/nonebot-plugin-parser/releases
27
+ Project-URL: Repository, https://github.com/fllesser/nonebot-plugin-parser
28
+ Provides-Extra: htmlkit
29
+ Description-Content-Type: text/markdown
30
+
31
+ <div align="center">
32
+ <a href="https://v2.nonebot.dev/store">
33
+ <img src="https://raw.githubusercontent.com/fllesser/nonebot-plugin-template/refs/heads/resource/.docs/NoneBotPlugin.svg" width="310" alt="logo">
34
+ </a>
35
+
36
+ ## ✨ [Nonebot2](https://github.com/nonebot/nonebot2) 链接分享自动解析插件 ✨
37
+ [![LICENSE](https://img.shields.io/github/license/fllesser/nonebot-plugin-parser.svg)](./LICENSE)
38
+ [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-parser.svg)](https://pypi.python.org/pypi/nonebot-plugin-parser)
39
+ [![python](https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg)](https://python.org)
40
+ [![uv](https://img.shields.io/badge/package%20manager-uv-black?style=flat-square&logo=uv)](https://github.com/astral-sh/uv)
41
+ [![ruff](https://img.shields.io/badge/code%20style-ruff-black?style=flat-square&logo=ruff)](https://github.com/astral-sh/ruff)
42
+ <br/>
43
+ [![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)
44
+ [![codecov](https://codecov.io/gh/fllesser/nonebot-plugin-parser/graph/badge.svg?token=VCS8IHSO7U)](https://codecov.io/gh/fllesser/nonebot-plugin-parser)
45
+ [![pepy](https://static.pepy.tech/badge/nonebot-plugin-parser)](https://pepy.tech/projects/nonebot-plugin-parser)
46
+
47
+ </div>
48
+
49
+ > [!IMPORTANT]
50
+ > **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
51
+
52
+ <img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=fllesser&repo=nonebot-plugin-parser" alt="starify" />
53
+
54
+ ## 📖 介绍
55
+
56
+ [nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver) 重制版
57
+
58
+ | 平台 | 触发的消息形态 | 视频 | 图集 | 音频 |
59
+ | ------- | ------------------------------------- | ---- | ---- | ---- |
60
+ | B站 | BV号/链接(包含短链,BV,av)/卡片/小程序 | ✅​ | ✅​ | ✅​ |
61
+ | 抖音 | 链接(分享链接,兼容电脑端链接) | ✅​ | ✅​ | ❌️ |
62
+ | 微博 | 链接(博文,视频,show) | ✅​ | ✅​ | ❌️ |
63
+ | 小红书 | 链接(含短链)/卡片 | ✅​ | ✅​ | ❌️ |
64
+ | 快手 | 链接(包含标准链接和短链) | ✅​ | ✅​ | ❌️ |
65
+ | acfun | 链接 | ✅​ | ❌️ | ❌️ |
66
+ | youtube | 链接(含短链) | ✅​ | ❌️ | ✅​ |
67
+ | tiktok | 链接 | ✅​ | ❌️ | ❌️ |
68
+ | twitter | 链接 | ✅​ | ✅​ | ❌️ |
69
+
70
+ 支持的链接,可参考 [测试链接](https://github.com/fllesser/nonebot-plugin-parser/blob/master/test_url.md)
71
+
72
+ ## 💿 安装
73
+ > [!Warning]
74
+ > **如果你已经在使用 nonebot-plugin-resolver,请在安装此插件前卸载**
75
+
76
+ <details open>
77
+ <summary>使用 nb-cli 安装/更新</summary>
78
+ 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
79
+
80
+ nb plugin install nonebot-plugin-parser --upgrade
81
+ 使用 pypi 源更新
82
+
83
+ nb plugin install nonebot-plugin-parser --upgrade -i https://pypi.org/simple
84
+ 安装仓库 dev 分支
85
+
86
+ uv pip install git+https://github.com/fllesser/nonebot-plugin-parser.git@dev
87
+ </details>
88
+
89
+ <details>
90
+ <summary>使用包管理器安装</summary>
91
+ 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
92
+ <details open>
93
+ <summary>uv</summary>
94
+ 使用 uv 安装
95
+
96
+ uv add nonebot-plugin-parser
97
+ 安装仓库 dev 分支
98
+
99
+ uv add git+https://github.com/fllesser/nonebot-plugin-parser.git@master
100
+ </details>
101
+
102
+
103
+ <details>
104
+ <summary>pip</summary>
105
+
106
+ pip install --upgrade nonebot-plugin-parser
107
+ </details>
108
+ <details>
109
+ <summary>pdm</summary>
110
+
111
+ pdm add nonebot-plugin-parser
112
+ </details>
113
+ <details>
114
+ <summary>poetry</summary>
115
+
116
+ poetry add nonebot-plugin-parser
117
+ </details>
118
+
119
+ 打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
120
+
121
+ plugins = ["nonebot_plugin_parser"]
122
+
123
+ </details>
124
+
125
+ <details open>
126
+ <summary>安装必要组件</summary>
127
+ 大部分解析都依赖于 ffmpeg
128
+
129
+ ubuntu/debian
130
+
131
+ sudo apt-get install ffmpeg
132
+
133
+ 其他 linux 参考(原项目推荐): https://gitee.com/baihu433/ffmpeg
134
+
135
+ Windows 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c
136
+ </details>
137
+
138
+ ## ⚙️ 配置
139
+
140
+ 在 nonebot2 项目的`.env`文件中添加下表中的必填配置
141
+
142
+ | 配置项 | 必填 | 默认值 | 说明 |
143
+ | :-----------------------: | :---: | :----------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
144
+ | NICKNAME | 否 | [""] | nonebot2 内置配置,可作为解析结果消息的前缀 |
145
+ | API_TIMEOUT | 否 | 30.0 | nonebot2 内置配置,若服务器上传带宽太低,建议调高,防止超时 |
146
+ | parser_bili_ck | 否 | "" | B 站 cookie, 必须含有 SESSDATA 项,可附加 B 站 AI 总结功能, 如果需要长期使用此凭据则不应该在**浏览器登录账户**导致 cookie 被刷新,建议注册个小号获取, 也可以配置 ac_time_value 项,用于凭据的自动刷新,[获取方式](https://github.com/fllesser/nonebot-plugin-parser/issues/177) |
147
+ | parser_bili_video_codes | 否 | '["avc", "av01", "hev"]' | 允许的 B 站视频编码,越靠前的编码优先级越高,可选 "avc"(H.264,体积较大), "hev"(HEVC), "av01"(AV1), 后两项在不同设备可能有兼容性问题,如需完全避免,可只填一项,如 '["avc"]' |
148
+ | parser_ytb_ck | 否 | "" | Youtube cookie, Youtube 视频因人机检测下载失败,需填 |
149
+ | parser_proxy | 否 | None | 仅作用于 youtube, tiktok 解析,推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置) |
150
+ | parser_need_upload | 否 | False | 音频解析,是否需要上传群文件 |
151
+ | parser_use_base64 | 否 | False | 视频,图片,音频是否使用 base64 发送,注意:编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃,因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置 |
152
+ | parser_duration_maximum | 否 | 480 | 视频最大解析时长,单位:_秒_ |
153
+ | parser_max_size | 否 | 90 | 音视频下载最大文件大小,单位 MB,超过该配置将阻断下载 |
154
+ | parser_disabled_platforms | 否 | [] | 全局禁止的解析,示例 parser_disabled_platforms=["bilibili", "douyin"] 表示禁止了哔哩哔哩和抖, 请根据自己需求填写["bilibili", "douyin", "kuaishou", "twitter", "youtube", "acfun", "tiktok", "weibo", "xiaohongshu"] |
155
+ | parser_render_type | 否 | "common" | 渲染器类型,可选 "default"(无图片渲染), "common"(PIL 通用图片渲染), "htmlkit"(htmlkit) |
156
+
157
+ ## 🎉 使用
158
+ ### 指令表
159
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
160
+ | :------: | :-------------------: | :---: | :---: | :------: |
161
+ | 开启解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 开启解析 |
162
+ | 关闭解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 关闭解析 |
163
+
164
+ ## 致谢
165
+ [nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver)
166
+ [parse-video-py](https://github.com/wujunwei928/parse-video-py)
@@ -0,0 +1,136 @@
1
+ <div align="center">
2
+ <a href="https://v2.nonebot.dev/store">
3
+ <img src="https://raw.githubusercontent.com/fllesser/nonebot-plugin-template/refs/heads/resource/.docs/NoneBotPlugin.svg" width="310" alt="logo">
4
+ </a>
5
+
6
+ ## ✨ [Nonebot2](https://github.com/nonebot/nonebot2) 链接分享自动解析插件 ✨
7
+ [![LICENSE](https://img.shields.io/github/license/fllesser/nonebot-plugin-parser.svg)](./LICENSE)
8
+ [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-parser.svg)](https://pypi.python.org/pypi/nonebot-plugin-parser)
9
+ [![python](https://img.shields.io/badge/python-3.10|3.11|3.12|3.13-blue.svg)](https://python.org)
10
+ [![uv](https://img.shields.io/badge/package%20manager-uv-black?style=flat-square&logo=uv)](https://github.com/astral-sh/uv)
11
+ [![ruff](https://img.shields.io/badge/code%20style-ruff-black?style=flat-square&logo=ruff)](https://github.com/astral-sh/ruff)
12
+ <br/>
13
+ [![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)
14
+ [![codecov](https://codecov.io/gh/fllesser/nonebot-plugin-parser/graph/badge.svg?token=VCS8IHSO7U)](https://codecov.io/gh/fllesser/nonebot-plugin-parser)
15
+ [![pepy](https://static.pepy.tech/badge/nonebot-plugin-parser)](https://pepy.tech/projects/nonebot-plugin-parser)
16
+
17
+ </div>
18
+
19
+ > [!IMPORTANT]
20
+ > **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
21
+
22
+ <img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=fllesser&repo=nonebot-plugin-parser" alt="starify" />
23
+
24
+ ## 📖 介绍
25
+
26
+ [nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver) 重制版
27
+
28
+ | 平台 | 触发的消息形态 | 视频 | 图集 | 音频 |
29
+ | ------- | ------------------------------------- | ---- | ---- | ---- |
30
+ | B站 | BV号/链接(包含短链,BV,av)/卡片/小程序 | ✅​ | ✅​ | ✅​ |
31
+ | 抖音 | 链接(分享链接,兼容电脑端链接) | ✅​ | ✅​ | ❌️ |
32
+ | 微博 | 链接(博文,视频,show) | ✅​ | ✅​ | ❌️ |
33
+ | 小红书 | 链接(含短链)/卡片 | ✅​ | ✅​ | ❌️ |
34
+ | 快手 | 链接(包含标准链接和短链) | ✅​ | ✅​ | ❌️ |
35
+ | acfun | 链接 | ✅​ | ❌️ | ❌️ |
36
+ | youtube | 链接(含短链) | ✅​ | ❌️ | ✅​ |
37
+ | tiktok | 链接 | ✅​ | ❌️ | ❌️ |
38
+ | twitter | 链接 | ✅​ | ✅​ | ❌️ |
39
+
40
+ 支持的链接,可参考 [测试链接](https://github.com/fllesser/nonebot-plugin-parser/blob/master/test_url.md)
41
+
42
+ ## 💿 安装
43
+ > [!Warning]
44
+ > **如果你已经在使用 nonebot-plugin-resolver,请在安装此插件前卸载**
45
+
46
+ <details open>
47
+ <summary>使用 nb-cli 安装/更新</summary>
48
+ 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
49
+
50
+ nb plugin install nonebot-plugin-parser --upgrade
51
+ 使用 pypi 源更新
52
+
53
+ nb plugin install nonebot-plugin-parser --upgrade -i https://pypi.org/simple
54
+ 安装仓库 dev 分支
55
+
56
+ uv pip install git+https://github.com/fllesser/nonebot-plugin-parser.git@dev
57
+ </details>
58
+
59
+ <details>
60
+ <summary>使用包管理器安装</summary>
61
+ 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
62
+ <details open>
63
+ <summary>uv</summary>
64
+ 使用 uv 安装
65
+
66
+ uv add nonebot-plugin-parser
67
+ 安装仓库 dev 分支
68
+
69
+ uv add git+https://github.com/fllesser/nonebot-plugin-parser.git@master
70
+ </details>
71
+
72
+
73
+ <details>
74
+ <summary>pip</summary>
75
+
76
+ pip install --upgrade nonebot-plugin-parser
77
+ </details>
78
+ <details>
79
+ <summary>pdm</summary>
80
+
81
+ pdm add nonebot-plugin-parser
82
+ </details>
83
+ <details>
84
+ <summary>poetry</summary>
85
+
86
+ poetry add nonebot-plugin-parser
87
+ </details>
88
+
89
+ 打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
90
+
91
+ plugins = ["nonebot_plugin_parser"]
92
+
93
+ </details>
94
+
95
+ <details open>
96
+ <summary>安装必要组件</summary>
97
+ 大部分解析都依赖于 ffmpeg
98
+
99
+ ubuntu/debian
100
+
101
+ sudo apt-get install ffmpeg
102
+
103
+ 其他 linux 参考(原项目推荐): https://gitee.com/baihu433/ffmpeg
104
+
105
+ Windows 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c
106
+ </details>
107
+
108
+ ## ⚙️ 配置
109
+
110
+ 在 nonebot2 项目的`.env`文件中添加下表中的必填配置
111
+
112
+ | 配置项 | 必填 | 默认值 | 说明 |
113
+ | :-----------------------: | :---: | :----------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
114
+ | NICKNAME | 否 | [""] | nonebot2 内置配置,可作为解析结果消息的前缀 |
115
+ | API_TIMEOUT | 否 | 30.0 | nonebot2 内置配置,若服务器上传带宽太低,建议调高,防止超时 |
116
+ | parser_bili_ck | 否 | "" | B 站 cookie, 必须含有 SESSDATA 项,可附加 B 站 AI 总结功能, 如果需要长期使用此凭据则不应该在**浏览器登录账户**导致 cookie 被刷新,建议注册个小号获取, 也可以配置 ac_time_value 项,用于凭据的自动刷新,[获取方式](https://github.com/fllesser/nonebot-plugin-parser/issues/177) |
117
+ | parser_bili_video_codes | 否 | '["avc", "av01", "hev"]' | 允许的 B 站视频编码,越靠前的编码优先级越高,可选 "avc"(H.264,体积较大), "hev"(HEVC), "av01"(AV1), 后两项在不同设备可能有兼容性问题,如需完全避免,可只填一项,如 '["avc"]' |
118
+ | parser_ytb_ck | 否 | "" | Youtube cookie, Youtube 视频因人机检测下载失败,需填 |
119
+ | parser_proxy | 否 | None | 仅作用于 youtube, tiktok 解析,推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置) |
120
+ | parser_need_upload | 否 | False | 音频解析,是否需要上传群文件 |
121
+ | parser_use_base64 | 否 | False | 视频,图片,音频是否使用 base64 发送,注意:编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃,因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置 |
122
+ | parser_duration_maximum | 否 | 480 | 视频最大解析时长,单位:_秒_ |
123
+ | parser_max_size | 否 | 90 | 音视频下载最大文件大小,单位 MB,超过该配置将阻断下载 |
124
+ | parser_disabled_platforms | 否 | [] | 全局禁止的解析,示例 parser_disabled_platforms=["bilibili", "douyin"] 表示禁止了哔哩哔哩和抖, 请根据自己需求填写["bilibili", "douyin", "kuaishou", "twitter", "youtube", "acfun", "tiktok", "weibo", "xiaohongshu"] |
125
+ | parser_render_type | 否 | "common" | 渲染器类型,可选 "default"(无图片渲染), "common"(PIL 通用图片渲染), "htmlkit"(htmlkit) |
126
+
127
+ ## 🎉 使用
128
+ ### 指令表
129
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
130
+ | :------: | :-------------------: | :---: | :---: | :------: |
131
+ | 开启解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 开启解析 |
132
+ | 关闭解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 关闭解析 |
133
+
134
+ ## 致谢
135
+ [nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver)
136
+ [parse-video-py](https://github.com/wujunwei928/parse-video-py)
@@ -0,0 +1,196 @@
1
+ [project]
2
+ name = "nonebot-plugin-parser"
3
+ version = "2.0.0"
4
+ description = "NoneBot2 链接分享解析器自动解析, BV号/链接/小程序/卡片 | B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun"
5
+ authors = [{ "name" = "fllesser", "email" = "fllessive@gmail.com" }]
6
+ readme = "README.md"
7
+ requires-python = ">=3.10"
8
+ keywords = [
9
+ "nonebot",
10
+ "nonebot2",
11
+ "video",
12
+ "bilibili",
13
+ "youtube",
14
+ "tiktok",
15
+ "twitter",
16
+ "kuaishou",
17
+ "acfun",
18
+ "weibo",
19
+ "xiaohongshu",
20
+ "nga",
21
+ "douyin",
22
+ ]
23
+ dependencies = [
24
+ "msgspec>=0.19.0,<1.0.0",
25
+ "httpx>=0.27.2,<1.0.0",
26
+ "tqdm>=4.67.1,<5.0.0",
27
+ "aiofiles>=24.1.0",
28
+ "pillow>=11.0.0",
29
+
30
+ # 后续改为可选依赖
31
+ "curl_cffi>=0.13.0,<1.0.0",
32
+ "bilibili-api-python>=17.3.0,<18.0.0",
33
+ "beautifulsoup4>=4.12.0,<5.0.0",
34
+ "yt-dlp>=2025.9.26",
35
+
36
+ "nonebot2>=2.4.3,<3.0.0",
37
+ "nonebot-plugin-localstore>=0.7.4,<1.0.0",
38
+ "nonebot-plugin-apscheduler>=0.5.0,<1.0.0",
39
+ "nonebot-plugin-alconna>=0.59.4",
40
+ "nonebot-plugin-uninfo>=0.9.0",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ htmlkit = ["nonebot-plugin-htmlkit>=0.1.0rc1", "jinja2>=3.1.6"]
45
+
46
+ [project.urls]
47
+ Repository = "https://github.com/fllesser/nonebot-plugin-parser"
48
+ IssueTracker = "https://github.com/fllesser/nonebot-plugin-parser/issues"
49
+ Release = "https://github.com/fllesser/nonebot-plugin-parser/releases"
50
+
51
+ [dependency-groups]
52
+ dev = [
53
+ "nb-cli>=1.4.2",
54
+ "nonebot2[fastapi]>=2.4.3,<3.0.0",
55
+ "nonebot-adapter-telegram>=0.1.0b20",
56
+ "pre-commit>=4.3.0",
57
+ "ruff>=0.13.3,<1.0.0",
58
+ "bump-my-version>=1.2.4",
59
+ ]
60
+
61
+ test = [
62
+ "nonebot2[fastapi]>=2.4.3,<3.0.0",
63
+ "nonebot-adapter-onebot>=2.4.6",
64
+ "nonebug>=0.4.3,<1.0.0",
65
+ "pytest-xdist>=3.8.0,<4.0.0",
66
+ "pytest-asyncio>=1.2.0,<1.3.0",
67
+ "pytest-cov>=7.0.0",
68
+ "poethepoet>=0.37.0",
69
+ "respx>=0.22.0",
70
+ ]
71
+
72
+ all_extras = ["nonebot-plugin-htmlkit>=0.1.0rc1", "jinja2>=3.1.6"]
73
+
74
+ [tool.uv]
75
+ required-version = ">=0.8.14"
76
+ default-groups = ["test", "dev", "all_extras"]
77
+
78
+ [tool.nonebot]
79
+ adapters = [
80
+ { "name" = "Onebot V11", module_name = "nonebot.adapters.onebot.v11" },
81
+ { name = "Telegram", module_name = "nonebot.adapters.telegram" },
82
+ ]
83
+ plugins = ["nonebot_plugin_parser"]
84
+
85
+
86
+ [tool.pytest.ini_options]
87
+ asyncio_mode = "auto"
88
+ asyncio_default_fixture_loop_scope = "session"
89
+ pythonpath = ["src"]
90
+ addopts = [
91
+ "-v", # 详细输出
92
+ "-s", # 显示打印信息
93
+ "--tb=short", # 简短的错误回溯
94
+ "-ra", # 显示所有测试结果摘要
95
+ "--strict-markers", # 严格标记模式
96
+ "--import-mode=prepend", # 导入模式
97
+ ]
98
+
99
+ [tool.poe.tasks]
100
+ test_others = "pytest tests/others --cov=src --cov-report=xml:coverage1.xml --junitxml=junit1.xml -n auto"
101
+ test_parsers = "pytest tests/parsers --cov=src --cov-report=xml:coverage2.xml --junitxml=junit2.xml -n auto"
102
+ bump = "bump-my-version bump"
103
+ show-bump = "bump-my-version show-bump"
104
+
105
+
106
+ [tool.coverage.report]
107
+ show_missing = true # 相当于 --cov-report=term-missing:cite[1]
108
+ # omit = [ # 排除不需要统计的文件
109
+
110
+ # ]
111
+ exclude_lines = [
112
+ "raise NotImplementedError",
113
+ "if TYPE_CHECKING:",
114
+ "@overload",
115
+ "except",
116
+ "raise",
117
+ ]
118
+
119
+ [tool.ruff]
120
+ line-length = 120
121
+ target-version = "py310"
122
+
123
+ [tool.ruff.format]
124
+ line-ending = "lf"
125
+
126
+ [tool.ruff.lint]
127
+ select = [
128
+ "F", # Pyflakes
129
+ "W", # pycodestyle warnings
130
+ "E", # pycodestyle errors
131
+ "I", # isort
132
+ "UP", # pyupgrade
133
+ "ASYNC", # flake8-async
134
+ "C4", # flake8-comprehensions
135
+ "T10", # flake8-debugger
136
+ "T20", # flake8-print
137
+ "PYI", # flake8-pyi
138
+ "PT", # flake8-pytest-style
139
+ "Q", # flake8-quotes
140
+ "TID", # flake8-tidy-imports
141
+ "RUF", # Ruff-specific rules
142
+ ]
143
+ ignore = [
144
+ "E402", # module-import-not-at-top-of-file
145
+ "UP037", # quoted-annotation
146
+ "RUF001", # ambiguous-unicode-character-string
147
+ "RUF002", # ambiguous-unicode-character-docstring
148
+ "RUF003", # ambiguous-unicode-character-comment
149
+ "W191", # indentation contains tabs
150
+ # "I001", # isort: imports are incorrectly sorted
151
+ "TID252", # 相对导入
152
+ ]
153
+
154
+
155
+ [tool.ruff.lint.isort]
156
+ force-sort-within-sections = true
157
+ known-first-party = ["tests/*"]
158
+ extra-standard-library = ["typing_extensions"]
159
+
160
+ [tool.ruff.lint.flake8-pytest-style]
161
+ fixture-parentheses = false
162
+ mark-parentheses = false
163
+
164
+ [tool.ruff.lint.pyupgrade]
165
+ keep-runtime-typing = true
166
+
167
+
168
+ [tool.pyright]
169
+ pythonVersion = "3.10"
170
+ pythonPlatform = "All"
171
+ defineConstant = { PYDANTIC_V2 = true }
172
+ executionEnvironments = [
173
+ { root = "./tests", extraPaths = [
174
+ "./src",
175
+ ] },
176
+ { root = "./src" },
177
+ ]
178
+ typeCheckingMode = "standard"
179
+ reportShadowedImports = false
180
+ disableBytesTypePromotions = true
181
+
182
+ [build-system]
183
+ requires = ["uv_build>=0.8.14,<0.9.0"]
184
+ build-backend = "uv_build"
185
+
186
+
187
+ [tool.bumpversion]
188
+ current_version = "2.0.0"
189
+ commit = true
190
+ message = "🔖 release: bump vesion from {current_version} to {new_version}"
191
+ tag = true
192
+
193
+ [[tool.bumpversion.files]]
194
+ filename = "uv.lock"
195
+ search = "name = \"nonebot-plugin-parser\"\nversion = \"{current_version}\""
196
+ replace = "name = \"nonebot-plugin-parser\"\nversion = \"{new_version}\""
@@ -0,0 +1,46 @@
1
+ import asyncio
2
+
3
+ from nonebot import logger, require
4
+ from nonebot.plugin import PluginMetadata, inherit_supported_adapters
5
+
6
+ require("nonebot_plugin_alconna")
7
+ require("nonebot_plugin_uninfo")
8
+
9
+ from .config import Config, pconfig
10
+ from .matchers import parser_matcher # noqa: F401
11
+ from .utils import safe_unlink
12
+
13
+ __plugin_meta__ = PluginMetadata(
14
+ name="链接分享自动解析",
15
+ description="BV号/链接/小程序/卡片 | B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun",
16
+ usage="发送支持平台的(BV号/链接/小程序/卡片)即可",
17
+ type="application",
18
+ homepage="https://github.com/fllesser/nonebot-plugin-parser",
19
+ config=Config,
20
+ supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna", "nonebot_plugin_uninfo"),
21
+ extra={
22
+ "author": "fllesser",
23
+ "email": "fllessive@gmail.com",
24
+ "homepage": "https://github.com/fllesser/nonebot-plugin-parser",
25
+ },
26
+ )
27
+
28
+ require("nonebot_plugin_apscheduler")
29
+ from nonebot_plugin_apscheduler import scheduler
30
+
31
+
32
+ @scheduler.scheduled_job("cron", hour=1, minute=0, id="parser-clean-local-cache")
33
+ async def clean_plugin_cache():
34
+ try:
35
+ files = [f for f in pconfig.cache_dir.iterdir() if f.is_file()]
36
+ if not files:
37
+ logger.info("No cache files to clean")
38
+ return
39
+
40
+ # 并发删除文件
41
+ tasks = [safe_unlink(file) for file in files]
42
+ await asyncio.gather(*tasks)
43
+
44
+ logger.success(f"Successfully cleaned {len(files)} cache files")
45
+ except Exception:
46
+ logger.exception("Error while cleaning cache files")