nonebot-plugin-jmdownloader 1.0.1__py3-none-any.whl → 1.0.3__py3-none-any.whl
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_jmdownloader/__init__.py +57 -51
- nonebot_plugin_jmdownloader/utils.py +4 -4
- {nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/METADATA +2 -2
- nonebot_plugin_jmdownloader-1.0.3.dist-info/RECORD +9 -0
- nonebot_plugin_jmdownloader-1.0.1.dist-info/RECORD +0 -9
- {nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/WHEEL +0 -0
- {nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@ import asyncio
|
|
|
2
2
|
import hashlib
|
|
3
3
|
import os
|
|
4
4
|
import random
|
|
5
|
+
from re import A
|
|
5
6
|
import shutil
|
|
6
7
|
import time
|
|
7
8
|
|
|
@@ -12,7 +13,7 @@ from nonebot import logger, on_command, require, get_bot
|
|
|
12
13
|
from nonebot.adapters.onebot.v11 import (GROUP_ADMIN, GROUP_OWNER,
|
|
13
14
|
ActionFailed, Bot, GroupMessageEvent,
|
|
14
15
|
Message, MessageEvent, MessageSegment,
|
|
15
|
-
PrivateMessageEvent)
|
|
16
|
+
PrivateMessageEvent, NetworkError)
|
|
16
17
|
from nonebot.params import ArgPlainText, CommandArg
|
|
17
18
|
from nonebot.permission import SUPERUSER
|
|
18
19
|
from nonebot.plugin import PluginMetadata
|
|
@@ -88,31 +89,36 @@ async def _(bot: Bot, event: MessageEvent, arg: Message = CommandArg()):
|
|
|
88
89
|
else:
|
|
89
90
|
await jm_download.finish("该本子(或其tag)被禁止下载!")
|
|
90
91
|
|
|
91
|
-
if str(user_id) not in bot.config.superusers:
|
|
92
|
-
data_manager.decrease_user_limit(user_id, 1)
|
|
93
|
-
user_limit_new = data_manager.get_user_limit(user_id)
|
|
94
|
-
message = Message()
|
|
95
|
-
message += f"jm{photo.id} | {photo.title}\n"
|
|
96
|
-
message += f"🎨 作者: {photo.author}\n"
|
|
97
|
-
message += "🔖 标签: " + " ".join(f"#{tag}" for tag in photo.tags) + "\n"
|
|
98
|
-
message += f"开始下载...\n你本周还有{user_limit_new}次下载次数!"
|
|
99
|
-
await jm_download.send(message)
|
|
100
|
-
else:
|
|
101
|
-
message = Message()
|
|
102
|
-
message += f"jm{photo.id} | {photo.title}\n"
|
|
103
|
-
message += f"🎨 作者: {photo.author}\n"
|
|
104
|
-
message += "🔖 标签: " + " ".join(f"#{tag}" for tag in photo.tags) + "\n"
|
|
105
|
-
message += "开始下载..."
|
|
106
|
-
await jm_download.send(message)
|
|
107
|
-
|
|
108
92
|
try:
|
|
109
|
-
|
|
93
|
+
if str(user_id) not in bot.config.superusers:
|
|
94
|
+
data_manager.decrease_user_limit(user_id, 1)
|
|
95
|
+
user_limit_new = data_manager.get_user_limit(user_id)
|
|
96
|
+
message = Message()
|
|
97
|
+
message += f"jm{photo.id} | {photo.title}\n"
|
|
98
|
+
message += f"🎨 作者: {photo.author}\n"
|
|
99
|
+
message += "🔖 标签: " + " ".join(f"#{tag}" for tag in photo.tags) + "\n"
|
|
100
|
+
message += f"开始下载...\n你本周还有{user_limit_new}次下载次数!"
|
|
101
|
+
await jm_download.send(message)
|
|
102
|
+
else:
|
|
103
|
+
message = Message()
|
|
104
|
+
message += f"jm{photo.id} | {photo.title}\n"
|
|
105
|
+
message += f"🎨 作者: {photo.author}\n"
|
|
106
|
+
message += "🔖 标签: " + " ".join(f"#{tag}" for tag in photo.tags) + "\n"
|
|
107
|
+
message += "开始下载..."
|
|
108
|
+
await jm_download.send(message)
|
|
109
|
+
except ActionFailed:
|
|
110
|
+
await jm_download.send("本子信息可能被屏蔽,已开始下载")
|
|
111
|
+
except NetworkError as e:
|
|
112
|
+
logger.warning(f"{e},可能是协议端发送文件时间太长导致的报错")
|
|
113
|
+
|
|
114
|
+
pdf_path = f"{cache_dir}/{photo.id}.pdf"
|
|
110
115
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
# 如果不存在,则下载
|
|
117
|
+
if not os.path.exists(pdf_path):
|
|
118
|
+
if not await download_photo_async(downloader, photo):
|
|
119
|
+
await jm_download.finish("下载失败")
|
|
115
120
|
|
|
121
|
+
try:
|
|
116
122
|
# 根据配置决定是否需要修改MD5
|
|
117
123
|
if plugin_config.jmcomic_modify_real_md5:
|
|
118
124
|
random_suffix = hashlib.md5(str(time.time() + random.random()).encode()).hexdigest()[:8]
|
|
@@ -121,41 +127,41 @@ async def _(bot: Bot, event: MessageEvent, arg: Message = CommandArg()):
|
|
|
121
127
|
modified = await asyncio.to_thread(modify_pdf_md5, pdf_path, renamed_pdf_path)
|
|
122
128
|
if modified:
|
|
123
129
|
pdf_path = renamed_pdf_path
|
|
130
|
+
except Exception as e:
|
|
131
|
+
logger.error(f"处理PDF文件时出错: {e}")
|
|
132
|
+
await jm_download.finish("处理文件失败")
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await bot.call_api(
|
|
139
|
-
"upload_group_file",
|
|
140
|
-
group_id=event.group_id,
|
|
141
|
-
file=pdf_path,
|
|
142
|
-
name=f"{photo.id}.pdf"
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
elif isinstance(event, PrivateMessageEvent):
|
|
134
|
+
try:
|
|
135
|
+
if isinstance(event, GroupMessageEvent):
|
|
136
|
+
folder_id = data_manager.get_group_folder_id(event.group_id)
|
|
137
|
+
|
|
138
|
+
if folder_id:
|
|
139
|
+
await bot.call_api(
|
|
140
|
+
"upload_group_file",
|
|
141
|
+
group_id=event.group_id,
|
|
142
|
+
file=pdf_path,
|
|
143
|
+
name=f"{photo.id}.pdf",
|
|
144
|
+
folder_id=folder_id
|
|
145
|
+
)
|
|
146
|
+
else:
|
|
146
147
|
await bot.call_api(
|
|
147
|
-
"
|
|
148
|
-
|
|
148
|
+
"upload_group_file",
|
|
149
|
+
group_id=event.group_id,
|
|
149
150
|
file=pdf_path,
|
|
150
151
|
name=f"{photo.id}.pdf"
|
|
151
152
|
)
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
await
|
|
154
|
+
elif isinstance(event, PrivateMessageEvent):
|
|
155
|
+
await bot.call_api(
|
|
156
|
+
"upload_private_file",
|
|
157
|
+
user_id=event.user_id,
|
|
158
|
+
file=pdf_path,
|
|
159
|
+
name=f"{photo.id}.pdf"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
except ActionFailed:
|
|
163
|
+
await jm_download.send("发送文件失败")
|
|
155
164
|
|
|
156
|
-
except Exception as e:
|
|
157
|
-
logger.error(f"处理PDF文件时出错: {e}")
|
|
158
|
-
await jm_download.send("处理文件失败")
|
|
159
165
|
|
|
160
166
|
|
|
161
167
|
jm_query = on_command("jm查询", aliases={"JM查询"}, block=True, rule=check_group_and_user)
|
|
@@ -43,17 +43,17 @@ async def get_photo_info_async(client: JmcomicClient, photo_id):
|
|
|
43
43
|
return await asyncio.to_thread(get_photo_info, client, photo_id)
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
def download_photo(
|
|
46
|
+
def download_photo(downloader: JmDownloader, photo: JmPhotoDetail):
|
|
47
47
|
try:
|
|
48
48
|
with downloader as dler:
|
|
49
|
-
dler.download_by_photo_detail(photo
|
|
49
|
+
dler.download_by_photo_detail(photo)
|
|
50
50
|
return True
|
|
51
51
|
except JmcomicException as e:
|
|
52
52
|
logger.error(f"JMComic 下载失败: {e}")
|
|
53
53
|
return False
|
|
54
54
|
|
|
55
|
-
async def download_photo_async(
|
|
56
|
-
return await asyncio.to_thread(download_photo,
|
|
55
|
+
async def download_photo_async(downloader: JmDownloader, photo: JmPhotoDetail):
|
|
56
|
+
return await asyncio.to_thread(download_photo, downloader, photo)
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
def search_album(client: JmcomicClient, search_query: str, page: int = 1):
|
{nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-jmdownloader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: 基于 Nonebot2 的 JMComic 插件
|
|
5
5
|
Author-email: Misty02600 <xiao02600@gmail.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/Misty02600/nonebot-plugin-jmdownloader
|
|
@@ -15,7 +15,7 @@ Requires-Dist: nonebot-plugin-waiter<1.0.0,>=0.8.1
|
|
|
15
15
|
Requires-Dist: nonebot-plugin-localstore<1.0.0,>=0.7.4
|
|
16
16
|
Requires-Dist: nonebot-plugin-apscheduler<1.0.0,>=0.5.0
|
|
17
17
|
Requires-Dist: nonebot-adapter-onebot<3.0.0,>=2.4.6
|
|
18
|
-
Requires-Dist: jmcomic>=2.5.
|
|
18
|
+
Requires-Dist: jmcomic>=2.5.35
|
|
19
19
|
Requires-Dist: pillow>=11.1.0
|
|
20
20
|
Requires-Dist: img2pdf>=0.6.0
|
|
21
21
|
Dynamic: license-file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
nonebot_plugin_jmdownloader/__init__.py,sha256=yHK1h2VyHdirwzc5IMF0HqZYv4R5bzgV41A-8rgbwxk,23535
|
|
2
|
+
nonebot_plugin_jmdownloader/config.py,sha256=6v9_tJMbA0w6BC-UWdwT2E7ENYqEEeyk9RoQVjF0FBA,2302
|
|
3
|
+
nonebot_plugin_jmdownloader/data_source.py,sha256=xWD9wxBpkSw0XNB7a94G6DUoms_uE_1_3IaRkLiyG_w,9425
|
|
4
|
+
nonebot_plugin_jmdownloader/utils.py,sha256=NHq3QryefW39MiszY1JuGR-EvUsjm5qgtW_pJ0GWeF4,7207
|
|
5
|
+
nonebot_plugin_jmdownloader-1.0.3.dist-info/licenses/LICENSE,sha256=tenc1Gy1mv_JaYJ084mXncDgF7lCA-37R_IHhtZ9GxQ,1062
|
|
6
|
+
nonebot_plugin_jmdownloader-1.0.3.dist-info/METADATA,sha256=a-ckSbodVXmpOyOrEdLdTPUPj2r3YAtvleX2xp6Hr4c,8641
|
|
7
|
+
nonebot_plugin_jmdownloader-1.0.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
8
|
+
nonebot_plugin_jmdownloader-1.0.3.dist-info/top_level.txt,sha256=zNFH1naQN94G9iYfnucKC0g4FM6ApV8x_D705Slo1aY,28
|
|
9
|
+
nonebot_plugin_jmdownloader-1.0.3.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
nonebot_plugin_jmdownloader/__init__.py,sha256=klXjYxXCCbC0ifFsFK6YAIdI9e2LbVB4dg_cNH6jxVc,23341
|
|
2
|
-
nonebot_plugin_jmdownloader/config.py,sha256=6v9_tJMbA0w6BC-UWdwT2E7ENYqEEeyk9RoQVjF0FBA,2302
|
|
3
|
-
nonebot_plugin_jmdownloader/data_source.py,sha256=xWD9wxBpkSw0XNB7a94G6DUoms_uE_1_3IaRkLiyG_w,9425
|
|
4
|
-
nonebot_plugin_jmdownloader/utils.py,sha256=K6Dx9vkQVsCTIhk5vnL-DXacajuXUslDjv1G0HYEhdg,7269
|
|
5
|
-
nonebot_plugin_jmdownloader-1.0.1.dist-info/licenses/LICENSE,sha256=tenc1Gy1mv_JaYJ084mXncDgF7lCA-37R_IHhtZ9GxQ,1062
|
|
6
|
-
nonebot_plugin_jmdownloader-1.0.1.dist-info/METADATA,sha256=HyTUX_8_DU_FUfak2_sxHPvI46cg4uyiswZ0F5pGX1s,8641
|
|
7
|
-
nonebot_plugin_jmdownloader-1.0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
8
|
-
nonebot_plugin_jmdownloader-1.0.1.dist-info/top_level.txt,sha256=zNFH1naQN94G9iYfnucKC0g4FM6ApV8x_D705Slo1aY,28
|
|
9
|
-
nonebot_plugin_jmdownloader-1.0.1.dist-info/RECORD,,
|
{nonebot_plugin_jmdownloader-1.0.1.dist-info → nonebot_plugin_jmdownloader-1.0.3.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|