nonebot-plugin-parser 2.5.1__tar.gz → 2.5.2__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 (65) hide show
  1. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/PKG-INFO +1 -1
  2. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/pyproject.toml +2 -2
  3. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/download/task.py +12 -4
  4. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/base.py +25 -16
  5. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/README.md +0 -0
  6. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/__init__.py +0 -0
  7. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/config.py +0 -0
  8. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/constants.py +0 -0
  9. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/download/__init__.py +0 -0
  10. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/download/ytdlp.py +0 -0
  11. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/exception.py +0 -0
  12. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/helper.py +0 -0
  13. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/matchers/__init__.py +0 -0
  14. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/matchers/filter.py +0 -0
  15. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/matchers/rule.py +0 -0
  16. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/__init__.py +0 -0
  17. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/acfun/__init__.py +0 -0
  18. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/acfun/video.py +0 -0
  19. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/base.py +0 -0
  20. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/__init__.py +0 -0
  21. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/article.py +0 -0
  22. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/common.py +0 -0
  23. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/dynamic.py +0 -0
  24. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/favlist.py +0 -0
  25. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/live.py +0 -0
  26. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/opus.py +0 -0
  27. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/bilibili/video.py +0 -0
  28. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/cookie.py +0 -0
  29. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/data.py +0 -0
  30. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/douyin/__init__.py +0 -0
  31. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/douyin/slides.py +0 -0
  32. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/douyin/video.py +0 -0
  33. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/kuaishou/__init__.py +0 -0
  34. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/kuaishou/states.py +0 -0
  35. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/nga.py +0 -0
  36. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/tiktok.py +0 -0
  37. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/twitter.py +0 -0
  38. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/weibo/__init__.py +0 -0
  39. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/weibo/article.py +0 -0
  40. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/weibo/common.py +0 -0
  41. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/weibo/show.py +0 -0
  42. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/xiaohongshu/__init__.py +0 -0
  43. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/xiaohongshu/common.py +0 -0
  44. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/xiaohongshu/discovery.py +0 -0
  45. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/xiaohongshu/explore.py +0 -0
  46. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/youtube/__init__.py +0 -0
  47. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/parsers/youtube/meta.py +0 -0
  48. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/__init__.py +0 -0
  49. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/common.py +0 -0
  50. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/default.py +0 -0
  51. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/htmlrender.py +0 -0
  52. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/HYSongYunLangHeiW.ttf +0 -0
  53. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/__init__.py +0 -0
  54. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/avatar.png +0 -0
  55. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/bilibili.png +0 -0
  56. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/douyin.png +0 -0
  57. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/kuaishou.png +0 -0
  58. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/play.png +0 -0
  59. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/tiktok.png +0 -0
  60. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/twitter.png +0 -0
  61. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/weibo.png +0 -0
  62. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/xiaohongshu.png +0 -0
  63. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/resources/youtube.png +0 -0
  64. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/src/nonebot_plugin_parser/renders/templates/card.html.jinja2 +0 -0
  65. {nonebot_plugin_parser-2.5.1 → nonebot_plugin_parser-2.5.2}/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.5.1
3
+ Version: 2.5.2
4
4
  Summary: NoneBot2 链接分享解析 Alconna 版, 现支持B站|抖音|快手|微博|小红书|YouTube|TikTok|Twitter|AcFun|NGA
5
5
  Keywords: acfun,bilibili,douyin,kuaishou,nga,nonebot,nonebot2,tiktok,twitter,video,weibo,xiaohongshu,youtube
6
6
  Author: fllesser
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-parser"
3
- version = "2.5.1"
3
+ version = "2.5.2"
4
4
  description = "NoneBot2 链接分享解析 Alconna 版, 现支持B站|抖音|快手|微博|小红书|YouTube|TikTok|Twitter|AcFun|NGA"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -118,7 +118,7 @@ nonebug = { git = "https://github.com/nonebot/nonebug", rev = "master" }
118
118
  [tool.bumpversion]
119
119
  tag = true
120
120
  commit = true
121
- current_version = "2.5.1"
121
+ current_version = "2.5.2"
122
122
  message = "release: bump vesion from {current_version} to {new_version}"
123
123
 
124
124
  [[tool.bumpversion.files]]
@@ -20,11 +20,16 @@ class PathTask:
20
20
  def __await__(self):
21
21
  return self.get().__await__()
22
22
 
23
- async def safe_get(self) -> Path | None:
23
+ async def safe_get(
24
+ self,
25
+ on_error: Callable[[Exception], None] | None = None,
26
+ ) -> Path | None:
24
27
  """任务失败, 返回 None"""
25
28
  try:
26
29
  return await self.get()
27
- except Exception:
30
+ except Exception as e:
31
+ if on_error is not None:
32
+ on_error(e)
28
33
  return None
29
34
 
30
35
  @property
@@ -52,11 +57,14 @@ class OptionalPathTask:
52
57
  def __await__(self):
53
58
  return self.get().__await__()
54
59
 
55
- async def safe_get(self) -> Path | None:
60
+ async def safe_get(
61
+ self,
62
+ on_error: Callable[[Exception], None] | None = None,
63
+ ) -> Path | None:
56
64
  """任务失败, 返回 None"""
57
65
  if self._path_task is None:
58
66
  return None
59
- return await self._path_task.safe_get()
67
+ return await self._path_task.safe_get(on_error)
60
68
 
61
69
  @property
62
70
  def uri(self) -> str | None:
@@ -36,25 +36,23 @@ class BaseRenderer(ABC):
36
36
  forwardable_segs: list[ForwardNodeInner] = []
37
37
  dynamic_segs: list[ForwardNodeInner] = []
38
38
 
39
+ def on_error(e: Exception):
40
+ if isinstance(e, IgnoreException):
41
+ pass
42
+ elif isinstance(e, DownloadException):
43
+ nonlocal failed_count
44
+ failed_count += 1
45
+
39
46
  if self.result.video:
40
- video_path = await self.result.video.path_task.get()
41
- yield UniMessage(UniHelper.video_seg(video_path))
47
+ if video_path := await self.result.video.path_task.safe_get(on_error):
48
+ yield UniMessage(UniHelper.video_seg(video_path))
42
49
 
43
50
  for cont in chain(
44
51
  self.result.contents,
45
- self.result.graphics,
46
- *(self.result.repost.contents, self.result.repost.graphics) if self.result.repost else (),
52
+ self.result.repost.contents if self.result.repost else (),
47
53
  ):
48
- if isinstance(cont, str):
49
- forwardable_segs.append(cont)
50
- continue
51
-
52
- try:
53
- path = await cont.path_task.get()
54
- except IgnoreException:
55
- continue
56
- except DownloadException:
57
- failed_count += 1
54
+ path = await cont.path_task.safe_get(on_error)
55
+ if path is None:
58
56
  continue
59
57
 
60
58
  match cont:
@@ -71,8 +69,19 @@ class BaseRenderer(ABC):
71
69
  dynamic_segs.append(UniHelper.video_seg(path))
72
70
 
73
71
  if self.result.repost and self.result.repost.video:
74
- video_path = await self.result.repost.video.path_task.get()
75
- yield UniMessage(UniHelper.video_seg(video_path))
72
+ if video_path := await self.result.repost.video.path_task.safe_get(on_error):
73
+ yield UniMessage(UniHelper.video_seg(video_path))
74
+
75
+ for cont in chain(
76
+ self.result.graphics,
77
+ self.result.repost.graphics if self.result.repost else (),
78
+ ):
79
+ if isinstance(cont, str):
80
+ forwardable_segs.append(cont)
81
+ continue
82
+
83
+ if path := await cont.path_task.safe_get(on_error):
84
+ forwardable_segs.append(UniHelper.img_seg(path))
76
85
 
77
86
  if forwardable_segs:
78
87
  if pconfig.need_forward_contents or len(forwardable_segs) > 4: