p115client 0.0.5.5.4__tar.gz → 0.0.5.5.4.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.
Files changed (22) hide show
  1. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/PKG-INFO +1 -1
  2. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/download.py +19 -5
  3. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/fs_files.py +20 -5
  4. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/pyproject.toml +1 -1
  5. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/LICENSE +0 -0
  6. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/__init__.py +0 -0
  7. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/_upload.py +0 -0
  8. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/client.py +0 -0
  9. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/const.py +0 -0
  10. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/exception.py +0 -0
  11. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/py.typed +0 -0
  12. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/__init__.py +0 -0
  13. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/edit.py +0 -0
  14. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/export_dir.py +0 -0
  15. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/iterdir.py +0 -0
  16. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/life.py +0 -0
  17. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/pool.py +0 -0
  18. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/request.py +0 -0
  19. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/upload.py +0 -0
  20. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/tool/xys.py +0 -0
  21. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/p115client/type.py +0 -0
  22. {p115client-0.0.5.5.4 → p115client-0.0.5.5.4.1}/readme.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p115client
3
- Version: 0.0.5.5.4
3
+ Version: 0.0.5.5.4.1
4
4
  Summary: Python 115 webdisk client.
5
5
  Home-page: https://github.com/ChenyangGao/p115client
6
6
  License: MIT
@@ -1089,7 +1089,7 @@ def make_strm(
1089
1089
  @overload
1090
1090
  def iter_download_nodes(
1091
1091
  client: str | P115Client,
1092
- pickcode: str,
1092
+ pickcode: int | str,
1093
1093
  files: bool = True,
1094
1094
  max_workers: None | int = 1,
1095
1095
  *,
@@ -1100,7 +1100,7 @@ def iter_download_nodes(
1100
1100
  @overload
1101
1101
  def iter_download_nodes(
1102
1102
  client: str | P115Client,
1103
- pickcode: str,
1103
+ pickcode: int | str,
1104
1104
  files: bool = True,
1105
1105
  max_workers: None | int = 1,
1106
1106
  *,
@@ -1110,7 +1110,7 @@ def iter_download_nodes(
1110
1110
  ...
1111
1111
  def iter_download_nodes(
1112
1112
  client: str | P115Client,
1113
- pickcode: str,
1113
+ pickcode: int | str,
1114
1114
  files: bool = True,
1115
1115
  max_workers: None | int = 1,
1116
1116
  *,
@@ -1134,9 +1134,14 @@ def iter_download_nodes(
1134
1134
  method = client.download_files
1135
1135
  else:
1136
1136
  method = client.download_folders
1137
- request_kwargs.setdefault("base_url", cycle(("http://proapi.115.com", "https://proapi.115.com")).__next__)
1138
1137
  if max_workers == 1:
1139
1138
  def gen_step():
1139
+ nonlocal pickcode
1140
+ if isinstance(pickcode, int):
1141
+ resp = yield client.fs_file_skim(pickcode, async_=async_, **request_kwargs)
1142
+ check_response(resp)
1143
+ pickcode = resp["data"][0]["pick_code"]
1144
+ request_kwargs.setdefault("base_url", cycle(("http://proapi.115.com", "https://proapi.115.com")).__next__)
1140
1145
  for i in count(1):
1141
1146
  payload = {"pickcode": pickcode, "page": i}
1142
1147
  resp = yield method(payload, async_=async_, **request_kwargs)
@@ -1174,7 +1179,7 @@ def iter_download_nodes(
1174
1179
  if not data["has_next_page"]:
1175
1180
  max_page = page
1176
1181
  def gen_step():
1177
- nonlocal max_workers
1182
+ nonlocal max_workers, pickcode
1178
1183
  if async_:
1179
1184
  if max_workers is None or max_workers <= 0:
1180
1185
  max_workers = 20
@@ -1191,6 +1196,15 @@ def iter_download_nodes(
1191
1196
  n = executor._max_workers
1192
1197
  submit = executor.submit
1193
1198
  shutdown = lambda: executor.shutdown(False, cancel_futures=True)
1199
+ if isinstance(pickcode, int):
1200
+ resp = yield client.fs_file_skim(
1201
+ pickcode,
1202
+ async_=async_, # type: ignore
1203
+ **request_kwargs,
1204
+ )
1205
+ check_response(resp)
1206
+ pickcode = resp["data"][0]["pick_code"]
1207
+ request_kwargs.setdefault("base_url", cycle(("http://proapi.115.com", "https://proapi.115.com")).__next__)
1194
1208
  try:
1195
1209
  sentinel = object()
1196
1210
  countdown: Callable
@@ -47,6 +47,7 @@ def iter_fs_files(
47
47
  /,
48
48
  first_page_size: int = 0,
49
49
  page_size: int = 10_000,
50
+ count: int = -1,
50
51
  callback: None | Callable[[dict], Any] = None,
51
52
  app: str = "web",
52
53
  raise_for_changed_count: bool = False,
@@ -62,6 +63,7 @@ def iter_fs_files(
62
63
  /,
63
64
  first_page_size: int = 0,
64
65
  page_size: int = 10_000,
66
+ count: int = -1,
65
67
  callback: None | Callable[[dict], Any] = None,
66
68
  app: str = "web",
67
69
  raise_for_changed_count: bool = False,
@@ -76,6 +78,7 @@ def iter_fs_files(
76
78
  /,
77
79
  first_page_size: int = 0,
78
80
  page_size: int = 10_000,
81
+ count: int = -1,
79
82
  callback: None | Callable[[dict], Any] = None,
80
83
  app: str = "web",
81
84
  raise_for_changed_count: bool = False,
@@ -89,6 +92,7 @@ def iter_fs_files(
89
92
  :param payload: 目录的 id 或者详细的查询参数
90
93
  :param first_page_size: 首次拉取的分页大小,如果 <= 0,则自动确定
91
94
  :param page_size: 分页大小,如果 <= 0,则自动确定
95
+ :param count: 文件总数
92
96
  :param callback: 回调函数,调用后,会获得一个值,会添加到返回值中,key 为 "callback"
93
97
  :param app: 使用此设备的接口
94
98
  :param raise_for_changed_count: 分批拉取时,发现总数发生变化后,是否报错
@@ -116,7 +120,6 @@ def iter_fs_files(
116
120
  else:
117
121
  request_kwargs.setdefault("base_url", get_proapi_origin)
118
122
  fs_files = partial(client.fs_files_app, app=app, async_=async_, **request_kwargs)
119
- count = -1
120
123
  def get_files(payload: dict, /):
121
124
  nonlocal count
122
125
  while True:
@@ -167,6 +170,8 @@ def iter_fs_files_threaded(
167
170
  payload: int | str | dict = 0,
168
171
  /,
169
172
  page_size: int = 7_000,
173
+ count: int = -1,
174
+ wait_for_count: bool = False,
170
175
  callback: None | Callable[[dict], Any] = None,
171
176
  app: str = "web",
172
177
  raise_for_changed_count: bool = False,
@@ -179,6 +184,8 @@ def iter_fs_files_threaded(
179
184
  :param client: 115 网盘客户端对象
180
185
  :param payload: 目录的 id 或者详细的查询参数
181
186
  :param page_size: 分页大小,如果 <= 0,则自动确定
187
+ :param count: 文件总数
188
+ :param wait_for_count: 如果为 True,则在确定 count 前,不进行并发
182
189
  :param callback: 回调函数,调用后,会获得一个值,会添加到返回值中,key 为 "callback"
183
190
  :param app: 使用此设备的接口
184
191
  :param raise_for_changed_count: 分批拉取时,发现总数发生变化后,是否报错
@@ -206,7 +213,6 @@ def iter_fs_files_threaded(
206
213
  else:
207
214
  request_kwargs.setdefault("base_url", get_proapi_origin)
208
215
  fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
209
- count = -1
210
216
  def get_files(payload: dict, /):
211
217
  nonlocal count
212
218
  resp = fs_files(payload)
@@ -245,7 +251,10 @@ def iter_fs_files_threaded(
245
251
  offset = payload["offset"]
246
252
  while True:
247
253
  try:
248
- resp = future.result(max(0, ts + cooldown - time()))
254
+ if wait_for_count and count < 0:
255
+ resp = future.result()
256
+ else:
257
+ resp = future.result(max(0, ts + cooldown - time()))
249
258
  except TimeoutError:
250
259
  payload["offset"] += page_size
251
260
  if count < 0 or payload["offset"] < count:
@@ -275,6 +284,8 @@ async def iter_fs_files_asynchronized(
275
284
  payload: int | str | dict = 0,
276
285
  /,
277
286
  page_size: int = 7_000,
287
+ count: int = -1,
288
+ wait_for_count: bool = False,
278
289
  callback: None | Callable[[dict], Any] = None,
279
290
  app: str = "web",
280
291
  raise_for_changed_count: bool = False,
@@ -286,6 +297,8 @@ async def iter_fs_files_asynchronized(
286
297
  :param client: 115 网盘客户端对象
287
298
  :param payload: 目录的 id 或者详细的查询参数
288
299
  :param page_size: 分页大小,如果 <= 0,则自动确定
300
+ :param count: 文件总数
301
+ :param wait_for_count: 如果为 True,则在确定 count 前,不进行并发
289
302
  :param callback: 回调函数,调用后,会获得一个值,会添加到返回值中,key 为 "callback"
290
303
  :param app: 使用此设备的接口
291
304
  :param raise_for_changed_count: 分批拉取时,发现总数发生变化后,是否报错
@@ -312,7 +325,6 @@ async def iter_fs_files_asynchronized(
312
325
  else:
313
326
  request_kwargs.setdefault("base_url", get_proapi_origin)
314
327
  fs_files = partial(client.fs_files_app, app=app, **request_kwargs)
315
- count = -1
316
328
  async def get_files(payload: dict, /):
317
329
  nonlocal count
318
330
  resp = await fs_files(payload, async_=True) # type: ignore
@@ -355,7 +367,10 @@ async def iter_fs_files_asynchronized(
355
367
  offset = payload["offset"]
356
368
  while True:
357
369
  try:
358
- resp = await wait_for(shield(task), max(0, ts + cooldown - time()))
370
+ if wait_for_count and count < 0:
371
+ resp = await task
372
+ else:
373
+ resp = await wait_for(shield(task), max(0, ts + cooldown - time()))
359
374
  except TimeoutError:
360
375
  payload["offset"] += page_size
361
376
  if count < 0 or payload["offset"] < count:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "p115client"
3
- version = "0.0.5.5.4"
3
+ version = "0.0.5.5.4.1"
4
4
  description = "Python 115 webdisk client."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
File without changes