p115client 0.0.5.5.5__py3-none-any.whl → 0.0.5.6.1__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.
- p115client/_upload.py +1 -1
- p115client/client.py +10682 -8495
- p115client/tool/fs_files.py +24 -15
- {p115client-0.0.5.5.5.dist-info → p115client-0.0.5.6.1.dist-info}/METADATA +35 -2
- {p115client-0.0.5.5.5.dist-info → p115client-0.0.5.6.1.dist-info}/RECORD +7 -7
- {p115client-0.0.5.5.5.dist-info → p115client-0.0.5.6.1.dist-info}/LICENSE +0 -0
- {p115client-0.0.5.5.5.dist-info → p115client-0.0.5.6.1.dist-info}/WHEEL +0 -0
p115client/tool/fs_files.py
CHANGED
@@ -19,7 +19,7 @@ from typing import cast, overload, Any, Final, Literal
|
|
19
19
|
from warnings import warn
|
20
20
|
|
21
21
|
from iterutils import run_gen_step, run_gen_step_iter, Yield
|
22
|
-
from p115client import check_response, P115Client
|
22
|
+
from p115client import check_response, P115Client, P115OpenClient
|
23
23
|
from p115client.client import get_status_code
|
24
24
|
from p115client.exception import BusyOSError, DataError, P115Warning
|
25
25
|
|
@@ -42,7 +42,7 @@ def is_timeouterror(exc: BaseException, /) -> bool:
|
|
42
42
|
|
43
43
|
@overload
|
44
44
|
def iter_fs_files(
|
45
|
-
client: str | P115Client,
|
45
|
+
client: str | P115Client | P115OpenClient,
|
46
46
|
payload: int | str | dict = 0,
|
47
47
|
/,
|
48
48
|
first_page_size: int = 0,
|
@@ -58,7 +58,7 @@ def iter_fs_files(
|
|
58
58
|
...
|
59
59
|
@overload
|
60
60
|
def iter_fs_files(
|
61
|
-
client: str | P115Client,
|
61
|
+
client: str | P115Client | P115OpenClient,
|
62
62
|
payload: int | str | dict = 0,
|
63
63
|
/,
|
64
64
|
first_page_size: int = 0,
|
@@ -73,7 +73,7 @@ def iter_fs_files(
|
|
73
73
|
) -> AsyncIterator[dict]:
|
74
74
|
...
|
75
75
|
def iter_fs_files(
|
76
|
-
client: str | P115Client,
|
76
|
+
client: str | P115Client | P115OpenClient,
|
77
77
|
payload: int | str | dict = 0,
|
78
78
|
/,
|
79
79
|
first_page_size: int = 0,
|
@@ -101,7 +101,7 @@ def iter_fs_files(
|
|
101
101
|
|
102
102
|
:return: 迭代器,每次返回一次接口调用的结果
|
103
103
|
"""
|
104
|
-
if
|
104
|
+
if isinstance(client, str):
|
105
105
|
client = P115Client(client, check_for_relogin=True)
|
106
106
|
if page_size <= 0:
|
107
107
|
page_size = 10_000
|
@@ -114,17 +114,20 @@ def iter_fs_files(
|
|
114
114
|
"limit": first_page_size, "show_dir": 1, **payload,
|
115
115
|
}
|
116
116
|
cid = int(payload["cid"])
|
117
|
-
if
|
117
|
+
if isinstance(client, P115OpenClient):
|
118
|
+
request_kwargs.setdefault("base_url", get_proapi_origin)
|
119
|
+
fs_files = partial(client.fs_files, **request_kwargs)
|
120
|
+
elif app in ("", "web", "desktop", "harmony"):
|
118
121
|
request_kwargs.setdefault("base_url", get_webapi_origin)
|
119
|
-
fs_files = partial(client.fs_files,
|
122
|
+
fs_files = partial(client.fs_files, **request_kwargs)
|
120
123
|
else:
|
121
124
|
request_kwargs.setdefault("base_url", get_proapi_origin)
|
122
|
-
fs_files = partial(client.fs_files_app, app=app,
|
125
|
+
fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
|
123
126
|
def get_files(payload: dict, /):
|
124
127
|
nonlocal count
|
125
128
|
while True:
|
126
129
|
try:
|
127
|
-
resp = yield fs_files(payload)
|
130
|
+
resp = yield fs_files(payload, async_=async_)
|
128
131
|
check_response(resp)
|
129
132
|
except DataError:
|
130
133
|
if payload["limit"] <= 1150:
|
@@ -166,7 +169,7 @@ def iter_fs_files(
|
|
166
169
|
|
167
170
|
|
168
171
|
def iter_fs_files_threaded(
|
169
|
-
client: str | P115Client,
|
172
|
+
client: str | P115Client | P115OpenClient,
|
170
173
|
payload: int | str | dict = 0,
|
171
174
|
/,
|
172
175
|
page_size: int = 7_000,
|
@@ -195,7 +198,7 @@ def iter_fs_files_threaded(
|
|
195
198
|
|
196
199
|
:return: 迭代器
|
197
200
|
"""
|
198
|
-
if
|
201
|
+
if isinstance(client, str):
|
199
202
|
client = P115Client(client, check_for_relogin=True)
|
200
203
|
if page_size <= 0:
|
201
204
|
page_size = 7_000
|
@@ -206,7 +209,10 @@ def iter_fs_files_threaded(
|
|
206
209
|
"limit": page_size, "show_dir": 1, **payload,
|
207
210
|
}
|
208
211
|
cid = int(payload["cid"])
|
209
|
-
if
|
212
|
+
if isinstance(client, P115OpenClient):
|
213
|
+
request_kwargs.setdefault("base_url", get_proapi_origin)
|
214
|
+
fs_files = partial(client.fs_files, **request_kwargs)
|
215
|
+
elif app in ("", "web", "desktop", "harmony"):
|
210
216
|
page_size = min(page_size, 1150)
|
211
217
|
request_kwargs.setdefault("base_url", get_webapi_origin)
|
212
218
|
fs_files = partial(client.fs_files, **request_kwargs)
|
@@ -280,7 +286,7 @@ def iter_fs_files_threaded(
|
|
280
286
|
|
281
287
|
|
282
288
|
async def iter_fs_files_asynchronized(
|
283
|
-
client: str | P115Client,
|
289
|
+
client: str | P115Client | P115OpenClient,
|
284
290
|
payload: int | str | dict = 0,
|
285
291
|
/,
|
286
292
|
page_size: int = 7_000,
|
@@ -307,7 +313,7 @@ async def iter_fs_files_asynchronized(
|
|
307
313
|
|
308
314
|
:return: 迭代器
|
309
315
|
"""
|
310
|
-
if
|
316
|
+
if isinstance(client, str):
|
311
317
|
client = P115Client(client, check_for_relogin=True)
|
312
318
|
if page_size <= 0:
|
313
319
|
page_size = 7_000
|
@@ -318,7 +324,10 @@ async def iter_fs_files_asynchronized(
|
|
318
324
|
"limit": page_size, "show_dir": 1, **payload,
|
319
325
|
}
|
320
326
|
cid = int(payload["cid"])
|
321
|
-
if
|
327
|
+
if isinstance(client, P115OpenClient):
|
328
|
+
request_kwargs.setdefault("base_url", get_proapi_origin)
|
329
|
+
fs_files = partial(client.fs_files, **request_kwargs)
|
330
|
+
elif app in ("", "web", "desktop", "harmony"):
|
322
331
|
page_size = min(page_size, 1150)
|
323
332
|
request_kwargs.setdefault("base_url", get_webapi_origin)
|
324
333
|
fs_files = partial(client.fs_files, **request_kwargs)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p115client
|
3
|
-
Version: 0.0.5.
|
3
|
+
Version: 0.0.5.6.1
|
4
4
|
Summary: Python 115 webdisk client.
|
5
5
|
Home-page: https://github.com/ChenyangGao/p115client
|
6
6
|
License: MIT
|
@@ -40,7 +40,7 @@ Requires-Dist: python-filewrap (>=0.2.6.1)
|
|
40
40
|
Requires-Dist: python-hashtools (>=0.0.3.3)
|
41
41
|
Requires-Dist: python-http_request (>=0.0.6)
|
42
42
|
Requires-Dist: python-httpfile (>=0.0.5)
|
43
|
-
Requires-Dist: python-iterutils (>=0.1.
|
43
|
+
Requires-Dist: python-iterutils (>=0.1.8)
|
44
44
|
Requires-Dist: python-property (>=0.0.3)
|
45
45
|
Requires-Dist: python-startfile (>=0.0.2)
|
46
46
|
Requires-Dist: python-undefined (>=0.0.3)
|
@@ -106,6 +106,39 @@ from pathlib import Path
|
|
106
106
|
client = P115Client(Path("~/115-cookies.txt").expanduser(), check_for_relogin=True)
|
107
107
|
```
|
108
108
|
|
109
|
+
如果你有一个申请通过的开放接口的应用,则可以创建开放接口的客户端实例
|
110
|
+
|
111
|
+
你可以直接从一个 `P115Client` 实例拿到授权(自动扫码登录并授权)
|
112
|
+
|
113
|
+
```python
|
114
|
+
app_id = <开放接口应用的 AppID>
|
115
|
+
client_open = client.login_another_open(app_id)
|
116
|
+
```
|
117
|
+
|
118
|
+
也可以用一个已经授权得到的 `refresh_token` (一次性使用)
|
119
|
+
|
120
|
+
```python
|
121
|
+
from p115client import P115OpenClient
|
122
|
+
|
123
|
+
client_open = P115OpenClient(refresh_token)
|
124
|
+
```
|
125
|
+
|
126
|
+
或者手动扫码登录
|
127
|
+
|
128
|
+
```python
|
129
|
+
client_open = P115OpenClient(app_id)
|
130
|
+
```
|
131
|
+
|
132
|
+
所以综上,推荐的初始化代码为
|
133
|
+
|
134
|
+
```python
|
135
|
+
from p115client import P115Client, P115OpenClient
|
136
|
+
from pathlib import Path
|
137
|
+
|
138
|
+
client = P115Client(Path("~/115-cookies.txt").expanduser(), check_for_relogin=True)
|
139
|
+
client_open = client.login_another_open(app_id)
|
140
|
+
```
|
141
|
+
|
109
142
|
### 2. 接口调用
|
110
143
|
|
111
144
|
所有需要直接或间接执行 HTTP 请求的接口,都有同步和异步的调用方式
|
@@ -1,7 +1,7 @@
|
|
1
1
|
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
2
2
|
p115client/__init__.py,sha256=1mx7njuAlqcuEWONTjSiiGnXyyNyqOcJyNX1FMHqQ-4,214
|
3
|
-
p115client/_upload.py,sha256=
|
4
|
-
p115client/client.py,sha256=
|
3
|
+
p115client/_upload.py,sha256=j2XHz6-hc9qyfiF92aZY-LPJ3UgbB6e4Jy6CNGQ5rwk,29904
|
4
|
+
p115client/client.py,sha256=ACDHsjrxhPCeEN44Dgtd6l3wUrIKDLUmQqQYs1_dHL4,695455
|
5
5
|
p115client/const.py,sha256=maIZfJAiUuEnXIKc8TMAyW_UboDUJPwYpPS8LjPFp_U,4321
|
6
6
|
p115client/exception.py,sha256=Ugjr__aSlYRDYwoOz7273ngV-gFX2z-ohsJmCba8nnQ,2657
|
7
7
|
p115client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -9,7 +9,7 @@ p115client/tool/__init__.py,sha256=2YrKoAcFYOuqu2nUBoPVhxMOseAvcLE_LcnbZV11UKw,3
|
|
9
9
|
p115client/tool/download.py,sha256=KY-8QHhCm_Mk-ygtuQXuPtoIIJHRWg5XNQQx0WDncGA,56232
|
10
10
|
p115client/tool/edit.py,sha256=NQiyVoOKKed6VbUj_AamGmTWXfcioOFqq5buFUWOh_8,16428
|
11
11
|
p115client/tool/export_dir.py,sha256=QFHK5HKllTV6ZgCnnf_BFd4CQq-gqcuLx49clcbvmDo,23871
|
12
|
-
p115client/tool/fs_files.py,sha256=
|
12
|
+
p115client/tool/fs_files.py,sha256=VxqFvpz-olfuiQu5Gz9RuXaZBE7OX8FOn49-suJUopE,16171
|
13
13
|
p115client/tool/iterdir.py,sha256=hpzOCaYi0-8XA6yS3RVnMp9a1FT25qjpZwnPJYNOXYw,183974
|
14
14
|
p115client/tool/life.py,sha256=8STXfjL8DPp0YTLFsE7Dt_6c2wj_0AvScq6WrjX9i9M,17583
|
15
15
|
p115client/tool/pool.py,sha256=vFV3t4g8KuQ4Rlttd1bs7d0Lc8jFUufdmDQweMcLZZw,9779
|
@@ -17,7 +17,7 @@ p115client/tool/request.py,sha256=SWsezW9EYZGS3R-TbZxMG-8bN3YWJ0-GzgvKlvRBSCM,70
|
|
17
17
|
p115client/tool/upload.py,sha256=qK1OQYxP-Faq2eMDhc5sBXJiSr8m8EZ_gb0O_iA2TrI,15915
|
18
18
|
p115client/tool/xys.py,sha256=6NZUkWNsWW6dHDBUpMitmE-1YlkobWIUQ86CBjKJ4mQ,3633
|
19
19
|
p115client/type.py,sha256=e4g9URQBE23XN2dGomldj8wC6NlDWBBSVC5Bmd8giBc,5993
|
20
|
-
p115client-0.0.5.
|
21
|
-
p115client-0.0.5.
|
22
|
-
p115client-0.0.5.
|
23
|
-
p115client-0.0.5.
|
20
|
+
p115client-0.0.5.6.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
21
|
+
p115client-0.0.5.6.1.dist-info/METADATA,sha256=wfF5vcyleLccNghmVcChGtRtNnn4hoUCGmUJe4p8cXY,7958
|
22
|
+
p115client-0.0.5.6.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
23
|
+
p115client-0.0.5.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|