nonebot-plugin-bittorrents 1.1.0__tar.gz → 1.1.1__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_bittorrents-1.1.0/nonebot_plugin_bittorrents.egg-info → nonebot_plugin_bittorrents-1.1.1}/PKG-INFO +5 -7
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/nonebot_plugin_BitTorrents/__init__.py +1 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/nonebot_plugin_BitTorrents/main.py +39 -33
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1/nonebot_plugin_bittorrents.egg-info}/PKG-INFO +5 -7
- nonebot_plugin_bittorrents-1.1.1/nonebot_plugin_bittorrents.egg-info/requires.txt +5 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/pyproject.toml +6 -8
- nonebot_plugin_bittorrents-1.1.0/nonebot_plugin_bittorrents.egg-info/requires.txt +0 -7
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/LICENSE +0 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/README.md +0 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/nonebot_plugin_bittorrents.egg-info/SOURCES.txt +0 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/nonebot_plugin_bittorrents.egg-info/dependency_links.txt +0 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/nonebot_plugin_bittorrents.egg-info/top_level.txt +0 -0
- {nonebot_plugin_bittorrents-1.1.0 → nonebot_plugin_bittorrents-1.1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-bittorrents
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: 适配NoneBot的磁力搜索插件,通过机器人帮你寻找电影、软件或者学习资料
|
|
5
5
|
Author: NightDust981989
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,12 +8,10 @@ Project-URL: homepage, https://github.com/NightDust981989/nonebot-plugin-BitTorr
|
|
|
8
8
|
Project-URL: repository, https://github.com/NightDust981989/nonebot-plugin-BitTorrents
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Requires-Dist: httpx
|
|
12
|
-
Requires-Dist: beautifulsoup4
|
|
13
|
-
Requires-Dist: lxml
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist: pydantic-settings
|
|
16
|
-
Requires-Dist: nonebot2
|
|
11
|
+
Requires-Dist: httpx>=0.23.0
|
|
12
|
+
Requires-Dist: beautifulsoup4>=4.11.0
|
|
13
|
+
Requires-Dist: lxml>=4.9.0
|
|
14
|
+
Requires-Dist: nonebot2>=2.3.0
|
|
17
15
|
Requires-Dist: nonebot-adapter-onebot
|
|
18
16
|
Dynamic: license-file
|
|
19
17
|
|
|
@@ -11,9 +11,11 @@ from nonebot.adapters import Message
|
|
|
11
11
|
from nonebot.params import CommandArg
|
|
12
12
|
|
|
13
13
|
try:
|
|
14
|
-
from pydantic import
|
|
14
|
+
from pydantic import BaseModel
|
|
15
|
+
from nonebot import get_plugin_config
|
|
15
16
|
except ImportError:
|
|
16
|
-
from
|
|
17
|
+
from pydantic import BaseSettings as BaseModel
|
|
18
|
+
from nonebot import get_driver
|
|
17
19
|
|
|
18
20
|
# ========== 1. 配置映射类(从配置文件读取参数) ==========
|
|
19
21
|
@dataclass
|
|
@@ -91,26 +93,34 @@ class MagnetSearchService:
|
|
|
91
93
|
self.client: httpx.AsyncClient = None
|
|
92
94
|
|
|
93
95
|
async def _init_client(self):
|
|
94
|
-
"""
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
"""初始化客户端"""
|
|
97
|
+
if self.client is None:
|
|
98
|
+
headers = {
|
|
99
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
100
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
101
|
+
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
102
|
+
"Origin": self.config.base_url,
|
|
103
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
104
|
+
"Referer": self.config.base_url
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
self.client = httpx.AsyncClient(
|
|
108
|
+
headers=headers,
|
|
109
|
+
cookies=self.config.captcha_cookies,
|
|
110
|
+
timeout=self.config.request_timeout, # 从配置读取超时时间
|
|
111
|
+
follow_redirects=False, # 关闭自动重定向
|
|
112
|
+
verify=False
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
async def close_client(self):
|
|
116
|
+
"""关闭客户端"""
|
|
117
|
+
if self.client:
|
|
118
|
+
await self.client.aclose()
|
|
119
|
+
self.client = None
|
|
111
120
|
|
|
112
121
|
async def search(self, keyword: str, sort_param: str = "") -> List[str]:
|
|
113
122
|
"""搜索逻辑:使用配置文件的站点/接口/结果数"""
|
|
123
|
+
# 确保客户端已初始化
|
|
114
124
|
await self._init_client()
|
|
115
125
|
results = []
|
|
116
126
|
|
|
@@ -215,28 +225,24 @@ class MagnetSearchService:
|
|
|
215
225
|
except Exception as e:
|
|
216
226
|
print(f"搜索异常:{str(e)}")
|
|
217
227
|
results = [f"搜索失败:{str(e)[:50]}"]
|
|
218
|
-
finally:
|
|
219
|
-
if self.client:
|
|
220
|
-
await self.client.aclose()
|
|
221
228
|
|
|
222
229
|
return results
|
|
223
230
|
|
|
224
|
-
# ========== 4.
|
|
225
|
-
|
|
226
|
-
from nonebot import get_driver
|
|
227
|
-
|
|
228
|
-
class Config(BaseSettings):
|
|
231
|
+
# ========== 4. 配置类定义 ==========
|
|
232
|
+
class Config(BaseModel):
|
|
229
233
|
magnet_base_url: str = "https://clg2.clgapp1.xyz"
|
|
230
234
|
magnet_search_path: str = "/cllj.php"
|
|
231
235
|
magnet_max_results: int = 3
|
|
232
236
|
magnet_request_timeout: int = 15
|
|
233
237
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
try:
|
|
239
|
+
plugin_config = get_plugin_config(Config)
|
|
240
|
+
except:
|
|
241
|
+
# 兜底
|
|
242
|
+
from nonebot import get_driver
|
|
243
|
+
driver = get_driver()
|
|
244
|
+
global_config = driver.config
|
|
245
|
+
plugin_config = Config(**global_config.dict())
|
|
240
246
|
|
|
241
247
|
# 初始化配置类
|
|
242
248
|
magnet_config = MagnetConfig(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-bittorrents
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: 适配NoneBot的磁力搜索插件,通过机器人帮你寻找电影、软件或者学习资料
|
|
5
5
|
Author: NightDust981989
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,12 +8,10 @@ Project-URL: homepage, https://github.com/NightDust981989/nonebot-plugin-BitTorr
|
|
|
8
8
|
Project-URL: repository, https://github.com/NightDust981989/nonebot-plugin-BitTorrents
|
|
9
9
|
Description-Content-Type: text/markdown
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Requires-Dist: httpx
|
|
12
|
-
Requires-Dist: beautifulsoup4
|
|
13
|
-
Requires-Dist: lxml
|
|
14
|
-
Requires-Dist:
|
|
15
|
-
Requires-Dist: pydantic-settings
|
|
16
|
-
Requires-Dist: nonebot2
|
|
11
|
+
Requires-Dist: httpx>=0.23.0
|
|
12
|
+
Requires-Dist: beautifulsoup4>=4.11.0
|
|
13
|
+
Requires-Dist: lxml>=4.9.0
|
|
14
|
+
Requires-Dist: nonebot2>=2.3.0
|
|
17
15
|
Requires-Dist: nonebot-adapter-onebot
|
|
18
16
|
Dynamic: license-file
|
|
19
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nonebot-plugin-bittorrents"
|
|
3
|
-
version = "1.1.
|
|
3
|
+
version = "1.1.1"
|
|
4
4
|
description = "适配NoneBot的磁力搜索插件,通过机器人帮你寻找电影、软件或者学习资料"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "NightDust981989"}
|
|
@@ -8,13 +8,11 @@ authors = [
|
|
|
8
8
|
license = "MIT"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"httpx",
|
|
12
|
-
"beautifulsoup4",
|
|
13
|
-
"lxml",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"nonebot2",
|
|
17
|
-
"nonebot-adapter-onebot"
|
|
11
|
+
"httpx>=0.23.0",
|
|
12
|
+
"beautifulsoup4>=4.11.0",
|
|
13
|
+
"lxml>=4.9.0",
|
|
14
|
+
"nonebot2>=2.3.0",
|
|
15
|
+
"nonebot-adapter-onebot",
|
|
18
16
|
]
|
|
19
17
|
|
|
20
18
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|