nonebot-plugin-parser 2.0.5__tar.gz → 2.0.7__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.
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/PKG-INFO +34 -19
- nonebot_plugin_parser-2.0.7/README.md +152 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/pyproject.toml +4 -3
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/__init__.py +4 -1
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/config.py +7 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/matchers/__init__.py +8 -3
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/base.py +15 -9
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/bilibili/__init__.py +179 -139
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/article.py +119 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/common.py +10 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/dynamic.py +198 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/favlist.py +66 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/live.py +72 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/parsers/bilibili/opus.py +144 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/bilibili/video.py +4 -9
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/data.py +32 -12
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/twitter.py +1 -1
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/weibo.py +3 -3
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/renders/__init__.py +1 -1
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/renders/base.py +84 -4
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/renders/common.py +441 -242
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/renders/default.py +8 -7
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/bilibili.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/douyin.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/kuaishou.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/media_button.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/tiktok.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/twitter.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/weibo.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/xiaohongshu.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources/youtube.png +0 -0
- nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/weibo.py +18 -0
- nonebot_plugin_parser-2.0.5/README.md +0 -137
- nonebot_plugin_parser-2.0.5/src/nonebot_plugin_parser/parsers/bilibili/opus.py +0 -0
- nonebot_plugin_parser-2.0.5/src/nonebot_plugin_parser/renders/weibo.py +0 -28
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/constants.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/download/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/download/task.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/download/ytdlp.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/exception.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/helper.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/matchers/filter.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/matchers/preprocess.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/acfun.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/cookie.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/douyin/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/douyin/slides.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/douyin/video.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/kuaishou.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/nga.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/tiktok.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/xiaohongshu.py +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/parsers/youtube.py +0 -0
- {nonebot_plugin_parser-2.0.5/src/nonebot_plugin_parser/renders/fonts → nonebot_plugin_parser-2.0.7/src/nonebot_plugin_parser/renders/resources}/HYSongYunLangHeiW-1.ttf +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/renders/templates/weibo.html.jinja +0 -0
- {nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nonebot-plugin-parser
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.7
|
|
4
4
|
Summary: NoneBot2 链接分享解析器自动解析, BV号/链接/小程序/卡片 | B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun
|
|
5
5
|
Keywords: nonebot,nonebot2,video,bilibili,youtube,tiktok,twitter,kuaishou,acfun,weibo,xiaohongshu,nga,douyin
|
|
6
6
|
Author: fllesser
|
|
@@ -121,9 +121,24 @@ Description-Content-Type: text/markdown
|
|
|
121
121
|
|
|
122
122
|
</details>
|
|
123
123
|
|
|
124
|
+
<details>
|
|
125
|
+
<summary>使用 nbr 安装(使用 uv 管理依赖可用)</summary>
|
|
126
|
+
|
|
127
|
+
[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2
|
|
128
|
+
|
|
129
|
+
nbr plugin install nonebot-plugin-parser
|
|
130
|
+
使用 **pypi** 源安装
|
|
131
|
+
|
|
132
|
+
nbr plugin install nonebot-plugin-parser -i "https://pypi.org/simple"
|
|
133
|
+
使用**清华源**安装
|
|
134
|
+
|
|
135
|
+
nbr plugin install nonebot-plugin-parser -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
136
|
+
|
|
137
|
+
</details>
|
|
138
|
+
|
|
124
139
|
<details open>
|
|
125
140
|
<summary>安装必要组件</summary>
|
|
126
|
-
|
|
141
|
+
部分解析依赖于 ffmpeg
|
|
127
142
|
|
|
128
143
|
ubuntu/debian
|
|
129
144
|
|
|
@@ -138,23 +153,23 @@ Windows 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c
|
|
|
138
153
|
|
|
139
154
|
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
|
140
155
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
156
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
|
157
|
+
| :--------------------------: | :---: | :----------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
158
|
+
| NICKNAME | 否 | [""] | nonebot2 内置配置,可作为解析结果消息的前缀 |
|
|
159
|
+
| API_TIMEOUT | 否 | 30.0 | nonebot2 内置配置,若服务器上传带宽太低,建议调高,防止超时 |
|
|
160
|
+
| parser_bili_ck | 否 | "" | B 站 cookie, 必须含有 SESSDATA 项,可附加 B 站 AI 总结功能, 如果需要长期使用此凭据则不应该在**浏览器登录账户**导致 cookie 被刷新,建议注册个小号获取, 也可以配置 ac_time_value 项,用于凭据的自动刷新,[获取方式](https://github.com/fllesser/nonebot-plugin-parser/issues/177) |
|
|
161
|
+
| parser_bili_video_codes | 否 | '["avc", "av01", "hev"]' | 允许的 B 站视频编码,越靠前的编码优先级越高,可选 "avc"(H.264,体积较大), "hev"(HEVC), "av01"(AV1), 后两项在不同设备可能有兼容性问题,如需完全避免,可只填一项,如 '["avc"]' |
|
|
162
|
+
| parser_ytb_ck | 否 | "" | Youtube cookie, Youtube 视频因人机检测下载失败,需填 |
|
|
163
|
+
| parser_proxy | 否 | None | 仅作用于 youtube, tiktok 解析,推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置) |
|
|
164
|
+
| parser_need_upload | 否 | False | 音频解析,是否需要上传群文件 |
|
|
165
|
+
| parser_use_base64 | 否 | False | 视频,图片,音频是否使用 base64 发送,注意:编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃,因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置 |
|
|
166
|
+
| parser_duration_maximum | 否 | 480 | 视频最大解析时长,单位:_秒_ |
|
|
167
|
+
| parser_max_size | 否 | 90 | 音视频下载最大文件大小,单位 MB,超过该配置将阻断下载 |
|
|
168
|
+
| parser_disabled_platforms | 否 | [] | 全局禁止的解析,示例 parser_disabled_platforms=["bilibili", "douyin"] 表示禁止了哔哩哔哩和抖, 请根据自己需求填写["bilibili", "douyin", "kuaishou", "twitter", "youtube", "acfun", "tiktok", "weibo", "xiaohongshu"] |
|
|
169
|
+
| parser_render_type | 否 | "common" | 渲染器类型,可选 "default"(无图片渲染), "common"(PIL 通用图片渲染), "htmlkit"(htmlkit, 暂不可用) |
|
|
170
|
+
| parser_append_url | 否 | False | 是否在解析结果中附加原始URL |
|
|
171
|
+
| parser_custom_font | 否 | None | 自定义渲染字体,配置字体文件名,并将字体文件放置于 localstore 生成的插件 data 目录下(如 ./data/nonebot_plugin_parser/) |
|
|
172
|
+
| parser_need_forward_contents | 否 | True | 是否需要转发媒体内容(超过 4 项时始终使用合并转发) |
|
|
158
173
|
## 🎉 使用
|
|
159
174
|
### 指令表
|
|
160
175
|
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|
|
@@ -0,0 +1,152 @@
|
|
|
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)
|
|
8
|
+
[](https://pypi.python.org/pypi/nonebot-plugin-parser)
|
|
9
|
+
[](https://python.org)
|
|
10
|
+
[](https://github.com/astral-sh/uv)
|
|
11
|
+
[](https://github.com/astral-sh/ruff)
|
|
12
|
+
<br/>
|
|
13
|
+
[](https://results.pre-commit.ci/latest/github/fllesser/nonebot-plugin-parser/master)
|
|
14
|
+
[](https://codecov.io/gh/fllesser/nonebot-plugin-parser)
|
|
15
|
+
[](https://qm.qq.com/q/y4T4CjHimc)
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
> [!IMPORTANT]
|
|
19
|
+
> **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
|
|
20
|
+
|
|
21
|
+
<img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=fllesser&repo=nonebot-plugin-parser" alt="starify" />
|
|
22
|
+
|
|
23
|
+
## 📖 介绍
|
|
24
|
+
|
|
25
|
+
[nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver) 重制版
|
|
26
|
+
|
|
27
|
+
| 平台 | 触发的消息形态 | 视频 | 图集 | 音频 |
|
|
28
|
+
| ------- | ------------------------------------- | ---- | ---- | ---- |
|
|
29
|
+
| B站 | BV号/链接(包含短链,BV,av)/卡片/小程序 | ✅ | ✅ | ✅ |
|
|
30
|
+
| 抖音 | 链接(分享链接,兼容电脑端链接) | ✅ | ✅ | ❌️ |
|
|
31
|
+
| 微博 | 链接(博文,视频,show) | ✅ | ✅ | ❌️ |
|
|
32
|
+
| 小红书 | 链接(含短链)/卡片 | ✅ | ✅ | ❌️ |
|
|
33
|
+
| 快手 | 链接(包含标准链接和短链) | ✅ | ✅ | ❌️ |
|
|
34
|
+
| acfun | 链接 | ✅ | ❌️ | ❌️ |
|
|
35
|
+
| youtube | 链接(含短链) | ✅ | ❌️ | ✅ |
|
|
36
|
+
| tiktok | 链接 | ✅ | ❌️ | ❌️ |
|
|
37
|
+
| twitter | 链接 | ✅ | ✅ | ❌️ |
|
|
38
|
+
|
|
39
|
+
支持的链接,可参考 [测试链接](https://github.com/fllesser/nonebot-plugin-parser/blob/master/test_url.md)
|
|
40
|
+
|
|
41
|
+
## 💿 安装
|
|
42
|
+
> [!Warning]
|
|
43
|
+
> **如果你已经在使用 nonebot-plugin-resolver,请在安装此插件前卸载**
|
|
44
|
+
|
|
45
|
+
<details open>
|
|
46
|
+
<summary>使用 nb-cli 安装/更新</summary>
|
|
47
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
|
48
|
+
|
|
49
|
+
nb plugin install nonebot-plugin-parser --upgrade
|
|
50
|
+
使用 pypi 源更新
|
|
51
|
+
|
|
52
|
+
nb plugin install nonebot-plugin-parser --upgrade -i https://pypi.org/simple
|
|
53
|
+
安装仓库 dev 分支
|
|
54
|
+
|
|
55
|
+
uv pip install git+https://github.com/fllesser/nonebot-plugin-parser.git@dev
|
|
56
|
+
</details>
|
|
57
|
+
|
|
58
|
+
<details>
|
|
59
|
+
<summary>使用包管理器安装</summary>
|
|
60
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
|
61
|
+
<details open>
|
|
62
|
+
<summary>uv</summary>
|
|
63
|
+
使用 uv 安装
|
|
64
|
+
|
|
65
|
+
uv add nonebot-plugin-parser
|
|
66
|
+
安装仓库 dev 分支
|
|
67
|
+
|
|
68
|
+
uv add git+https://github.com/fllesser/nonebot-plugin-parser.git@master
|
|
69
|
+
</details>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<details>
|
|
73
|
+
<summary>pip</summary>
|
|
74
|
+
|
|
75
|
+
pip install --upgrade nonebot-plugin-parser
|
|
76
|
+
</details>
|
|
77
|
+
<details>
|
|
78
|
+
<summary>pdm</summary>
|
|
79
|
+
|
|
80
|
+
pdm add nonebot-plugin-parser
|
|
81
|
+
</details>
|
|
82
|
+
<details>
|
|
83
|
+
<summary>poetry</summary>
|
|
84
|
+
|
|
85
|
+
poetry add nonebot-plugin-parser
|
|
86
|
+
</details>
|
|
87
|
+
|
|
88
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
|
|
89
|
+
|
|
90
|
+
plugins = ["nonebot_plugin_parser"]
|
|
91
|
+
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary>使用 nbr 安装(使用 uv 管理依赖可用)</summary>
|
|
96
|
+
|
|
97
|
+
[nbr](https://github.com/fllesser/nbr) 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2
|
|
98
|
+
|
|
99
|
+
nbr plugin install nonebot-plugin-parser
|
|
100
|
+
使用 **pypi** 源安装
|
|
101
|
+
|
|
102
|
+
nbr plugin install nonebot-plugin-parser -i "https://pypi.org/simple"
|
|
103
|
+
使用**清华源**安装
|
|
104
|
+
|
|
105
|
+
nbr plugin install nonebot-plugin-parser -i "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
106
|
+
|
|
107
|
+
</details>
|
|
108
|
+
|
|
109
|
+
<details open>
|
|
110
|
+
<summary>安装必要组件</summary>
|
|
111
|
+
部分解析依赖于 ffmpeg
|
|
112
|
+
|
|
113
|
+
ubuntu/debian
|
|
114
|
+
|
|
115
|
+
sudo apt-get install ffmpeg
|
|
116
|
+
|
|
117
|
+
其他 linux 参考(原项目推荐): https://gitee.com/baihu433/ffmpeg
|
|
118
|
+
|
|
119
|
+
Windows 参考(原项目推荐): https://www.jianshu.com/p/5015a477de3c
|
|
120
|
+
</details>
|
|
121
|
+
|
|
122
|
+
## ⚙️ 配置
|
|
123
|
+
|
|
124
|
+
在 nonebot2 项目的`.env`文件中添加下表中的必填配置
|
|
125
|
+
|
|
126
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
|
127
|
+
| :--------------------------: | :---: | :----------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
128
|
+
| NICKNAME | 否 | [""] | nonebot2 内置配置,可作为解析结果消息的前缀 |
|
|
129
|
+
| API_TIMEOUT | 否 | 30.0 | nonebot2 内置配置,若服务器上传带宽太低,建议调高,防止超时 |
|
|
130
|
+
| parser_bili_ck | 否 | "" | B 站 cookie, 必须含有 SESSDATA 项,可附加 B 站 AI 总结功能, 如果需要长期使用此凭据则不应该在**浏览器登录账户**导致 cookie 被刷新,建议注册个小号获取, 也可以配置 ac_time_value 项,用于凭据的自动刷新,[获取方式](https://github.com/fllesser/nonebot-plugin-parser/issues/177) |
|
|
131
|
+
| parser_bili_video_codes | 否 | '["avc", "av01", "hev"]' | 允许的 B 站视频编码,越靠前的编码优先级越高,可选 "avc"(H.264,体积较大), "hev"(HEVC), "av01"(AV1), 后两项在不同设备可能有兼容性问题,如需完全避免,可只填一项,如 '["avc"]' |
|
|
132
|
+
| parser_ytb_ck | 否 | "" | Youtube cookie, Youtube 视频因人机检测下载失败,需填 |
|
|
133
|
+
| parser_proxy | 否 | None | 仅作用于 youtube, tiktok 解析,推特解析会自动读取环境变量中的 http_proxy / https_proxy(代理软件通常会自动设置) |
|
|
134
|
+
| parser_need_upload | 否 | False | 音频解析,是否需要上传群文件 |
|
|
135
|
+
| parser_use_base64 | 否 | False | 视频,图片,音频是否使用 base64 发送,注意:编解码和传输 base64 会占用更多的内存,性能和带宽, 甚至可能会使 websocket 连接崩溃,因此该配置项仅推荐 nonebot 和 协议端不在同一机器的用户配置 |
|
|
136
|
+
| parser_duration_maximum | 否 | 480 | 视频最大解析时长,单位:_秒_ |
|
|
137
|
+
| parser_max_size | 否 | 90 | 音视频下载最大文件大小,单位 MB,超过该配置将阻断下载 |
|
|
138
|
+
| parser_disabled_platforms | 否 | [] | 全局禁止的解析,示例 parser_disabled_platforms=["bilibili", "douyin"] 表示禁止了哔哩哔哩和抖, 请根据自己需求填写["bilibili", "douyin", "kuaishou", "twitter", "youtube", "acfun", "tiktok", "weibo", "xiaohongshu"] |
|
|
139
|
+
| parser_render_type | 否 | "common" | 渲染器类型,可选 "default"(无图片渲染), "common"(PIL 通用图片渲染), "htmlkit"(htmlkit, 暂不可用) |
|
|
140
|
+
| parser_append_url | 否 | False | 是否在解析结果中附加原始URL |
|
|
141
|
+
| parser_custom_font | 否 | None | 自定义渲染字体,配置字体文件名,并将字体文件放置于 localstore 生成的插件 data 目录下(如 ./data/nonebot_plugin_parser/) |
|
|
142
|
+
| parser_need_forward_contents | 否 | True | 是否需要转发媒体内容(超过 4 项时始终使用合并转发) |
|
|
143
|
+
## 🎉 使用
|
|
144
|
+
### 指令表
|
|
145
|
+
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|
|
146
|
+
| :------: | :-------------------: | :---: | :---: | :------: |
|
|
147
|
+
| 开启解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 开启解析 |
|
|
148
|
+
| 关闭解析 | SUPERUSER/OWNER/ADMIN | 是 | 群聊 | 关闭解析 |
|
|
149
|
+
|
|
150
|
+
## 致谢
|
|
151
|
+
[nonebot-plugin-resolver](https://github.com/zhiyu1998/nonebot-plugin-resolver)
|
|
152
|
+
[parse-video-py](https://github.com/wujunwei928/parse-video-py)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-parser"
|
|
3
|
-
version = "2.0.
|
|
3
|
+
version = "2.0.7"
|
|
4
4
|
description = "NoneBot2 链接分享解析器自动解析, BV号/链接/小程序/卡片 | B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun"
|
|
5
5
|
authors = [{ "name" = "fllesser", "email" = "fllessive@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -99,6 +99,7 @@ addopts = [
|
|
|
99
99
|
[tool.poe.tasks]
|
|
100
100
|
test_others = "pytest tests/others --cov=src --cov-report=xml:coverage1.xml --junitxml=junit1.xml -n auto"
|
|
101
101
|
test_parsers = "pytest tests/parsers --cov=src --cov-report=xml:coverage2.xml --junitxml=junit2.xml -n auto"
|
|
102
|
+
test_render = "pytest tests/render --cov=src --cov-report=xml:coverage3.xml --junitxml=junit3.xml -n auto --log-cli-level=DEBUG"
|
|
102
103
|
bump = "bump-my-version bump"
|
|
103
104
|
show-bump = "bump-my-version show-bump"
|
|
104
105
|
|
|
@@ -180,12 +181,12 @@ reportShadowedImports = false
|
|
|
180
181
|
disableBytesTypePromotions = true
|
|
181
182
|
|
|
182
183
|
[build-system]
|
|
183
|
-
requires = ["uv_build>=0.
|
|
184
|
+
requires = ["uv_build>=0.9.0,<0.10.0"]
|
|
184
185
|
build-backend = "uv_build"
|
|
185
186
|
|
|
186
187
|
|
|
187
188
|
[tool.bumpversion]
|
|
188
|
-
current_version = "2.0.
|
|
189
|
+
current_version = "2.0.7"
|
|
189
190
|
commit = true
|
|
190
191
|
message = "🔖 release: bump vesion from {current_version} to {new_version}"
|
|
191
192
|
tag = true
|
{nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/__init__.py
RENAMED
|
@@ -7,7 +7,7 @@ require("nonebot_plugin_alconna")
|
|
|
7
7
|
require("nonebot_plugin_uninfo")
|
|
8
8
|
|
|
9
9
|
from .config import Config, pconfig
|
|
10
|
-
from .matchers import
|
|
10
|
+
from .matchers import clear_result_cache
|
|
11
11
|
from .utils import safe_unlink
|
|
12
12
|
|
|
13
13
|
__plugin_meta__ = PluginMetadata(
|
|
@@ -44,3 +44,6 @@ async def clean_plugin_cache():
|
|
|
44
44
|
logger.success(f"Successfully cleaned {len(files)} cache files")
|
|
45
45
|
except Exception:
|
|
46
46
|
logger.exception("Error while cleaning cache files")
|
|
47
|
+
|
|
48
|
+
# 资源清理完毕后,清理 result 缓存
|
|
49
|
+
clear_result_cache()
|
{nonebot_plugin_parser-2.0.5 → nonebot_plugin_parser-2.0.7}/src/nonebot_plugin_parser/config.py
RENAMED
|
@@ -53,6 +53,8 @@ class Config(BaseModel):
|
|
|
53
53
|
"""Renderer 类型"""
|
|
54
54
|
parser_custom_font: str | None = None
|
|
55
55
|
"""自定义字体"""
|
|
56
|
+
parser_need_forward_contents: bool = True
|
|
57
|
+
"""是否需要转发媒体内容"""
|
|
56
58
|
|
|
57
59
|
@property
|
|
58
60
|
def nickname(self) -> str:
|
|
@@ -134,6 +136,11 @@ class Config(BaseModel):
|
|
|
134
136
|
"""自定义字体"""
|
|
135
137
|
return (self.data_dir / self.parser_custom_font) if self.parser_custom_font else None
|
|
136
138
|
|
|
139
|
+
@property
|
|
140
|
+
def need_forward_contents(self) -> bool:
|
|
141
|
+
"""是否需要转发媒体内容"""
|
|
142
|
+
return self.parser_need_forward_contents
|
|
143
|
+
|
|
137
144
|
|
|
138
145
|
pconfig: Config = get_plugin_config(Config)
|
|
139
146
|
"""配置"""
|
|
@@ -46,7 +46,12 @@ def build_keyword_parsers_map():
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
# 缓存结果
|
|
49
|
-
|
|
49
|
+
_RESULT_CACHE = LimitedSizeDict[str, ParseResult](max_size=50)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def clear_result_cache():
|
|
53
|
+
_RESULT_CACHE.clear()
|
|
54
|
+
|
|
50
55
|
|
|
51
56
|
parser_matcher = on_keyword_regex(*_get_enabled_patterns())
|
|
52
57
|
|
|
@@ -63,7 +68,7 @@ async def _(
|
|
|
63
68
|
|
|
64
69
|
cache_key = matched.group(0)
|
|
65
70
|
# 1. 获取缓存结果
|
|
66
|
-
result =
|
|
71
|
+
result = _RESULT_CACHE.get(cache_key)
|
|
67
72
|
if result is None:
|
|
68
73
|
# 2. 获取对应平台 parser
|
|
69
74
|
parser = KEYWORD_PARSER_MAP[keyword]
|
|
@@ -88,7 +93,7 @@ async def _(
|
|
|
88
93
|
raise
|
|
89
94
|
|
|
90
95
|
# 4. 无 raise 再缓存解析结果
|
|
91
|
-
|
|
96
|
+
_RESULT_CACHE[cache_key] = result
|
|
92
97
|
|
|
93
98
|
# 5. 添加成功的消息响应
|
|
94
99
|
await _message_reaction(event, "done")
|
|
@@ -110,10 +110,9 @@ class BaseParser(ABC):
|
|
|
110
110
|
if cover_url:
|
|
111
111
|
cover_task = DOWNLOADER.download_img(cover_url, ext_headers=self.headers)
|
|
112
112
|
if isinstance(url_or_task, str):
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return VideoContent(video_task, cover_task, duration)
|
|
113
|
+
url_or_task = DOWNLOADER.download_video(url_or_task, ext_headers=self.headers)
|
|
114
|
+
|
|
115
|
+
return VideoContent(url_or_task, cover_task, duration)
|
|
117
116
|
|
|
118
117
|
def create_image_contents(self, image_urls: list[str]):
|
|
119
118
|
"""创建图片内容列表"""
|
|
@@ -124,7 +123,7 @@ class BaseParser(ABC):
|
|
|
124
123
|
return [ImageContent(task) for task in img_tasks]
|
|
125
124
|
|
|
126
125
|
def create_dynamic_contents(self, dynamic_urls: list[str]):
|
|
127
|
-
"""
|
|
126
|
+
"""创建动态图片内容列表"""
|
|
128
127
|
from ..download import DOWNLOADER
|
|
129
128
|
from .data import DynamicContent
|
|
130
129
|
|
|
@@ -137,7 +136,14 @@ class BaseParser(ABC):
|
|
|
137
136
|
from .data import AudioContent
|
|
138
137
|
|
|
139
138
|
if isinstance(url_or_task, str):
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
url_or_task = DOWNLOADER.download_audio(url_or_task, ext_headers=self.headers)
|
|
140
|
+
|
|
141
|
+
return AudioContent(url_or_task, duration)
|
|
142
|
+
|
|
143
|
+
def create_graphics_content(self, image_url: str, text: str | None = None, alt: str | None = None):
|
|
144
|
+
"""创建图文内容 图片不能为空 文字可空 渲染时文字在前 图片在后"""
|
|
145
|
+
from ..download import DOWNLOADER
|
|
146
|
+
from .data import GraphicsContent
|
|
147
|
+
|
|
148
|
+
image_task = DOWNLOADER.download_img(image_url, ext_headers=self.headers)
|
|
149
|
+
return GraphicsContent(image_task, text, alt)
|