nonebot-plugin-parser 2.0.14__tar.gz → 2.1.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.
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/PKG-INFO +1 -1
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/pyproject.toml +2 -2
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/matchers/preprocess.py +38 -37
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/__init__.py +1 -1
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/README.md +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/config.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/constants.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/download/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/download/task.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/download/ytdlp.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/exception.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/helper.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/matchers/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/matchers/filter.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/acfun.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/base.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/article.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/common.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/dynamic.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/favlist.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/live.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/opus.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/bilibili/video.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/cookie.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/data.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/douyin/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/douyin/slides.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/douyin/video.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/kuaishou.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/nga.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/tiktok.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/twitter.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/weibo.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/xiaohongshu.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/parsers/youtube.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/__init__.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/base.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/common.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/default.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/HYSongYunLangHeiW-1.ttf +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/bilibili.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/douyin.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/kuaishou.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/media_button.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/tiktok.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/twitter.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/weibo.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/xiaohongshu.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/resources/youtube.png +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/templates/weibo.html.jinja +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/renders/weibo.py +0 -0
- {nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/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.1.0
|
|
4
4
|
Summary: NoneBot2 链接分享解析 Alconna 版, 通用媒体卡片渲染(PIL 实现), 支持 B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun/nga
|
|
5
5
|
Keywords: nonebot,nonebot2,video,bilibili,youtube,tiktok,twitter,kuaishou,acfun,weibo,xiaohongshu,nga,douyin
|
|
6
6
|
Author: fllesser
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-parser"
|
|
3
|
-
version = "2.0
|
|
3
|
+
version = "2.1.0"
|
|
4
4
|
description = "NoneBot2 链接分享解析 Alconna 版, 通用媒体卡片渲染(PIL 实现), 支持 B站/抖音/快手/微博/小红书/youtube/tiktok/twitter/acfun/nga"
|
|
5
5
|
authors = [{ "name" = "fllesser", "email" = "fllessive@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -195,7 +195,7 @@ build-backend = "uv_build"
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
[tool.bumpversion]
|
|
198
|
-
current_version = "2.0
|
|
198
|
+
current_version = "2.1.0"
|
|
199
199
|
commit = true
|
|
200
200
|
message = "🔖 release: bump vesion from {current_version} to {new_version}"
|
|
201
201
|
tag = true
|
|
@@ -4,7 +4,8 @@ from typing import Any, Literal
|
|
|
4
4
|
|
|
5
5
|
from nonebot import logger
|
|
6
6
|
from nonebot.matcher import Matcher
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
# from nonebot.message import event_preprocessor
|
|
8
9
|
from nonebot.params import Depends
|
|
9
10
|
from nonebot.plugin.on import get_matcher_source
|
|
10
11
|
from nonebot.rule import Rule
|
|
@@ -42,30 +43,22 @@ def _kwd_regex_matched(state: T_State) -> re.Match[str] | None:
|
|
|
42
43
|
return state.get(PSR_KWD_MATCHED_KEY)
|
|
43
44
|
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"music": "jumpUrl",
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
CHAR_REPLACEMENTS = {",": ",", "\\": "", "&": "&"}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def _clean_url(url: str) -> str:
|
|
55
|
-
"""清理 URL 中的特殊字符
|
|
56
|
-
|
|
46
|
+
def _escape_raw(raw: str) -> str:
|
|
47
|
+
"""
|
|
48
|
+
转义原始字符串中的特殊字符
|
|
57
49
|
Args:
|
|
58
|
-
|
|
50
|
+
raw: 原始字符串
|
|
59
51
|
|
|
60
52
|
Returns:
|
|
61
|
-
str:
|
|
53
|
+
str: 转义后的字符串
|
|
62
54
|
"""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
replacements = [(",", ","), ("\\", ""), ("&", "&")]
|
|
56
|
+
for old, new in replacements:
|
|
57
|
+
raw = raw.replace(old, new)
|
|
58
|
+
return raw
|
|
66
59
|
|
|
67
60
|
|
|
68
|
-
def
|
|
61
|
+
def _extract_url(hyper: Hyper) -> str | None:
|
|
69
62
|
"""处理 JSON 类型的消息段,提取 URL
|
|
70
63
|
|
|
71
64
|
Args:
|
|
@@ -75,12 +68,12 @@ def _extract_json_url(hyper: Hyper) -> str | None:
|
|
|
75
68
|
Optional[str]: 提取的 URL, 如果提取失败则返回 None
|
|
76
69
|
"""
|
|
77
70
|
data = hyper.data
|
|
78
|
-
raw_str = data.get("raw")
|
|
71
|
+
raw_str: str | None = data.get("raw")
|
|
79
72
|
|
|
80
73
|
if raw_str is None:
|
|
81
74
|
return None
|
|
82
|
-
|
|
83
|
-
raw_str = raw_str
|
|
75
|
+
|
|
76
|
+
raw_str = _escape_raw(raw_str)
|
|
84
77
|
|
|
85
78
|
try:
|
|
86
79
|
raw: dict[str, Any] = json.loads(raw_str)
|
|
@@ -92,24 +85,23 @@ def _extract_json_url(hyper: Hyper) -> str | None:
|
|
|
92
85
|
if not meta:
|
|
93
86
|
return None
|
|
94
87
|
|
|
95
|
-
for key1, key2 in
|
|
96
|
-
if
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
for key1, key2 in [("detail_1", "qqdocurl"), ("news", "jumpUrl"), ("music", "jumpUrl")]:
|
|
89
|
+
if url := meta.get(key1, {}).get(key2):
|
|
90
|
+
logger.debug(f"extract url from raw:{key1}:{key2}: {url}")
|
|
91
|
+
return url
|
|
99
92
|
return None
|
|
100
93
|
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return
|
|
95
|
+
# 纪念我写了一个存在了一年没人发现的 bug ()
|
|
96
|
+
# @event_preprocessor
|
|
97
|
+
# async def extract_msg_text(message: UniMsg, state: T_State):
|
|
98
|
+
# if hyper := next(iter(message.get(Hyper, 1)), None):
|
|
99
|
+
# state[PSR_EXTRACT_KEY] = _extract_url(hyper)
|
|
100
|
+
# return
|
|
109
101
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
# # 提取纯文本
|
|
103
|
+
# if text := message.extract_plain_text().strip():
|
|
104
|
+
# state[PSR_EXTRACT_KEY] = text
|
|
113
105
|
|
|
114
106
|
|
|
115
107
|
class KeyPatternList(list[tuple[str, re.Pattern[str]]]):
|
|
@@ -138,14 +130,23 @@ class KeywordRegexRule:
|
|
|
138
130
|
def __hash__(self) -> int:
|
|
139
131
|
return hash(frozenset(self.key_pattern_list))
|
|
140
132
|
|
|
141
|
-
async def __call__(self,
|
|
133
|
+
async def __call__(self, message: UniMsg, state: T_State) -> bool:
|
|
134
|
+
text: str | None = None
|
|
135
|
+
if hyper := next(iter(message.get(Hyper, 1)), None):
|
|
136
|
+
text = _extract_url(hyper)
|
|
137
|
+
|
|
138
|
+
elif plain_text := message.extract_plain_text().strip():
|
|
139
|
+
text = plain_text
|
|
140
|
+
|
|
142
141
|
if not text:
|
|
143
142
|
return False
|
|
143
|
+
|
|
144
144
|
for keyword, pattern in self.key_pattern_list:
|
|
145
145
|
if keyword not in text:
|
|
146
146
|
continue
|
|
147
147
|
if matched := pattern.search(text):
|
|
148
148
|
state[PSR_KWD_KEY] = keyword
|
|
149
|
+
state[PSR_EXTRACT_KEY] = text
|
|
149
150
|
state[PSR_KWD_MATCHED_KEY] = matched
|
|
150
151
|
return True
|
|
151
152
|
logger.debug(f"keyword '{keyword}' is in '{text}', but not matched")
|
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/__init__.py
RENAMED
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/config.py
RENAMED
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/exception.py
RENAMED
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/helper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nonebot_plugin_parser-2.0.14 → nonebot_plugin_parser-2.1.0}/src/nonebot_plugin_parser/utils.py
RENAMED
|
File without changes
|