p115client 0.0.5.14.4__py3-none-any.whl → 0.0.5.15.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/client.py +665 -523
- p115client/tool/download.py +1 -0
- p115client/tool/edit.py +91 -12
- p115client/tool/iterdir.py +80 -55
- {p115client-0.0.5.14.4.dist-info → p115client-0.0.5.15.1.dist-info}/METADATA +1 -1
- {p115client-0.0.5.14.4.dist-info → p115client-0.0.5.15.1.dist-info}/RECORD +8 -8
- {p115client-0.0.5.14.4.dist-info → p115client-0.0.5.15.1.dist-info}/LICENSE +0 -0
- {p115client-0.0.5.14.4.dist-info → p115client-0.0.5.15.1.dist-info}/WHEEL +0 -0
p115client/tool/download.py
CHANGED
p115client/tool/edit.py
CHANGED
@@ -5,6 +5,7 @@ __author__ = "ChenyangGao <https://chenyanggao.github.io>"
|
|
5
5
|
__all__ = [
|
6
6
|
"update_abstract", "update_desc", "update_star", "update_label", "update_score",
|
7
7
|
"update_top", "update_show_play_long", "update_category_shortcut", "batch_unstar",
|
8
|
+
"post_event",
|
8
9
|
]
|
9
10
|
__doc__ = "这个模块提供了一些和修改文件或目录信息有关的函数"
|
10
11
|
|
@@ -71,16 +72,13 @@ def update_abstract(
|
|
71
72
|
"""
|
72
73
|
if isinstance(client, str):
|
73
74
|
client = P115Client(client, check_for_relogin=True)
|
74
|
-
if max_workers is None or max_workers <= 0:
|
75
|
-
max_workers = 20 if async_ else None
|
76
|
-
ids = do_map(to_id, ids)
|
77
75
|
def gen_step():
|
78
76
|
setter = partial(getattr(client, method), async_=async_, **request_kwargs)
|
79
77
|
def call(batch, /):
|
80
78
|
return check_response(setter(batch, value))
|
81
79
|
yield through(conmap(
|
82
80
|
call,
|
83
|
-
chunked(ids, batch_size),
|
81
|
+
chunked(do_map(to_id, ids), batch_size),
|
84
82
|
max_workers=max_workers,
|
85
83
|
async_=async_,
|
86
84
|
))
|
@@ -130,7 +128,7 @@ def update_desc(
|
|
130
128
|
"""批量给文件或目录设置备注,此举可更新此文件或目录的 mtime
|
131
129
|
|
132
130
|
:param client: 115 客户端或 cookies
|
133
|
-
:param ids: 一组文件或目录的 id
|
131
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
134
132
|
:param desc: 备注文本
|
135
133
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
136
134
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -201,7 +199,7 @@ def update_star(
|
|
201
199
|
如果一批中有任何一个 id 已经被删除,则这一批直接失败报错
|
202
200
|
|
203
201
|
:param client: 115 客户端或 cookies
|
204
|
-
:param ids: 一组文件或目录的 id
|
202
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
205
203
|
:param star: 是否设置星标
|
206
204
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
207
205
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -273,7 +271,7 @@ def update_label(
|
|
273
271
|
"""批量给文件或目录设置标签
|
274
272
|
|
275
273
|
:param client: 115 客户端或 cookies
|
276
|
-
:param ids: 一组文件或目录的 id
|
274
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
277
275
|
:param label: 标签 id,多个用逗号 "," 隔开,如果用一个根本不存在的 id,效果就是清空标签列表
|
278
276
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
279
277
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -338,7 +336,7 @@ def update_score(
|
|
338
336
|
"""批量给文件或目录设置分数
|
339
337
|
|
340
338
|
:param client: 115 客户端或 cookies
|
341
|
-
:param ids: 一组文件或目录的 id
|
339
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
342
340
|
:param score: 分数
|
343
341
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
344
342
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -397,7 +395,7 @@ def update_top(
|
|
397
395
|
"""批量给文件或目录设置置顶
|
398
396
|
|
399
397
|
:param client: 115 客户端或 cookies
|
400
|
-
:param ids: 一组文件或目录的 id
|
398
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
401
399
|
:param score: 分数
|
402
400
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
403
401
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -459,7 +457,7 @@ def update_show_play_long(
|
|
459
457
|
"""批量给目录设置显示时长
|
460
458
|
|
461
459
|
:param client: 115 客户端或 cookies
|
462
|
-
:param ids: 一组目录的 id
|
460
|
+
:param ids: 一组目录的 id 或 pickcode
|
463
461
|
:param show: 是否显示时长
|
464
462
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
465
463
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -524,7 +522,7 @@ def update_category_shortcut(
|
|
524
522
|
"""批量给目录设置显示时长
|
525
523
|
|
526
524
|
:param client: 115 客户端或 cookies
|
527
|
-
:param ids: 一组目录的 id
|
525
|
+
:param ids: 一组目录的 id 或 pickcode
|
528
526
|
:param set: 是否设为快捷入口
|
529
527
|
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
530
528
|
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
@@ -627,4 +625,85 @@ def batch_unstar(
|
|
627
625
|
)
|
628
626
|
return run_gen_step(gen_step, async_)
|
629
627
|
|
630
|
-
|
628
|
+
|
629
|
+
@overload
|
630
|
+
def post_event(
|
631
|
+
client: str | P115Client,
|
632
|
+
ids: Iterable[int | str],
|
633
|
+
/,
|
634
|
+
type: Literal["doc", "img"] = "doc",
|
635
|
+
batch_size: int = 10_000,
|
636
|
+
max_workers: None | int = None,
|
637
|
+
app: str = "android",
|
638
|
+
*,
|
639
|
+
async_: Literal[False] = False,
|
640
|
+
**request_kwargs,
|
641
|
+
):
|
642
|
+
...
|
643
|
+
@overload
|
644
|
+
def post_event(
|
645
|
+
client: str | P115Client,
|
646
|
+
ids: Iterable[int | str] | AsyncIterable[int | str],
|
647
|
+
/,
|
648
|
+
type: Literal["doc", "img"] = "doc",
|
649
|
+
batch_size: int = 10_000,
|
650
|
+
max_workers: None | int = None,
|
651
|
+
app: str = "android",
|
652
|
+
*,
|
653
|
+
async_: Literal[True],
|
654
|
+
**request_kwargs,
|
655
|
+
) -> Coroutine:
|
656
|
+
...
|
657
|
+
def post_event(
|
658
|
+
client: str | P115Client,
|
659
|
+
ids: Iterable[int | str] | AsyncIterable[int | str],
|
660
|
+
/,
|
661
|
+
type: Literal["doc", "img"] = "doc",
|
662
|
+
batch_size: int = 10_000,
|
663
|
+
max_workers: None | int = None,
|
664
|
+
app: str = "android",
|
665
|
+
*,
|
666
|
+
async_: Literal[False, True] = False,
|
667
|
+
**request_kwargs,
|
668
|
+
):
|
669
|
+
"""批量将文件或目录推送事件
|
670
|
+
|
671
|
+
.. note::
|
672
|
+
如果一批中有任何一个 id 已经被删除,则这一批直接失败报错
|
673
|
+
|
674
|
+
:param client: 115 客户端或 cookies
|
675
|
+
:param ids: 一组文件或目录的 id 或 pickcode
|
676
|
+
:param type: 事件类型
|
677
|
+
|
678
|
+
- "doc": 推送 "browse_document" 事件
|
679
|
+
- "img": 推送 "browse_image" 事件
|
680
|
+
|
681
|
+
:param batch_size: 批次大小,分批次,每次提交的 id 数
|
682
|
+
:param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
|
683
|
+
:param app: 使用此设备的接口
|
684
|
+
:param async_: 是否异步
|
685
|
+
:param request_kwargs: 其它请求参数
|
686
|
+
"""
|
687
|
+
if isinstance(client, str):
|
688
|
+
client = P115Client(client, check_for_relogin=True)
|
689
|
+
if type == "doc":
|
690
|
+
post = client.life_behavior_doc_post_app
|
691
|
+
else:
|
692
|
+
post = client.life_behavior_img_post_app
|
693
|
+
def call(batch, /):
|
694
|
+
return check_response(post(
|
695
|
+
batch,
|
696
|
+
app=app,
|
697
|
+
async_=async_,
|
698
|
+
request_kwargs=request_kwargs,
|
699
|
+
))
|
700
|
+
def gen_step():
|
701
|
+
yield through(conmap(
|
702
|
+
call,
|
703
|
+
chunked(do_map(to_id, ids), batch_size),
|
704
|
+
max_workers=max_workers,
|
705
|
+
async_=async_,
|
706
|
+
))
|
707
|
+
return run_gen_step(gen_step, async_)
|
708
|
+
|
709
|
+
# TODO: 上面这些,有些要支持 open 接口
|
p115client/tool/iterdir.py
CHANGED
@@ -13,9 +13,9 @@ __all__ = [
|
|
13
13
|
"iter_files", "iter_files_with_path", "iter_files_with_path_skim",
|
14
14
|
"traverse_tree", "traverse_tree_with_path", "iter_nodes",
|
15
15
|
"iter_nodes_skim", "iter_nodes_by_pickcode", "iter_nodes_using_update",
|
16
|
-
"iter_nodes_using_info", "
|
16
|
+
"iter_nodes_using_info", "iter_nodes_using_event",
|
17
17
|
"iter_dir_nodes_using_star", "iter_parents", "iter_files_shortcut",
|
18
|
-
"iter_dupfiles", "
|
18
|
+
"iter_dupfiles", "iter_media_files", "search_iter", "share_iterdir",
|
19
19
|
"share_iter_files", "share_search_iter",
|
20
20
|
]
|
21
21
|
__doc__ = "这个模块提供了一些和目录信息罗列有关的函数"
|
@@ -47,7 +47,7 @@ from typing import cast, overload, Any, Final, Literal, NamedTuple
|
|
47
47
|
from warnings import warn
|
48
48
|
|
49
49
|
from asynctools import to_list
|
50
|
-
from concurrenttools import run_as_thread,
|
50
|
+
from concurrenttools import run_as_thread, conmap
|
51
51
|
from iterutils import (
|
52
52
|
as_gen_step, bfs_gen, chunked, chain, chain_from_iterable, collect, foreach,
|
53
53
|
run_gen_step, run_gen_step_iter, through, with_iter_next, map as do_map,
|
@@ -64,7 +64,7 @@ from p115pickcode import pickcode_to_id, to_id
|
|
64
64
|
from posixpatht import path_is_dir_form, splitext, splits
|
65
65
|
|
66
66
|
from .attr import type_of_attr
|
67
|
-
from .edit import update_desc, update_star
|
67
|
+
from .edit import update_desc, update_star, post_event
|
68
68
|
from .fs_files import (
|
69
69
|
is_timeouterror, iter_fs_files, iter_fs_files_threaded,
|
70
70
|
iter_fs_files_asynchronized,
|
@@ -1549,7 +1549,7 @@ def ensure_attr_path_using_star_event[D: dict](
|
|
1549
1549
|
find_ids: set[int]
|
1550
1550
|
while pids:
|
1551
1551
|
if find_ids := pids - id_to_dirnode.keys() - dangling_ids:
|
1552
|
-
yield through(
|
1552
|
+
yield through(iter_nodes_using_event(
|
1553
1553
|
client,
|
1554
1554
|
find_ids,
|
1555
1555
|
normalize_attr=None,
|
@@ -2203,7 +2203,7 @@ def iter_files(
|
|
2203
2203
|
- 5: 压缩包
|
2204
2204
|
- 6: 应用
|
2205
2205
|
- 7: 书籍
|
2206
|
-
- 99:
|
2206
|
+
- 99: 所有文件
|
2207
2207
|
|
2208
2208
|
:param order: 排序
|
2209
2209
|
|
@@ -2225,7 +2225,7 @@ def iter_files(
|
|
2225
2225
|
:param async_: 是否异步
|
2226
2226
|
:param request_kwargs: 其它请求参数
|
2227
2227
|
|
2228
|
-
:return:
|
2228
|
+
:return: 迭代器,返回此目录内的(所有文件)文件信息
|
2229
2229
|
"""
|
2230
2230
|
suffix = suffix.strip(".")
|
2231
2231
|
if not (type or suffix):
|
@@ -2340,7 +2340,7 @@ def iter_files_with_path(
|
|
2340
2340
|
- 5: 压缩包
|
2341
2341
|
- 6: 应用
|
2342
2342
|
- 7: 书籍
|
2343
|
-
- 99:
|
2343
|
+
- 99: 所有文件
|
2344
2344
|
|
2345
2345
|
:param order: 排序
|
2346
2346
|
|
@@ -2371,7 +2371,7 @@ def iter_files_with_path(
|
|
2371
2371
|
:param async_: 是否异步
|
2372
2372
|
:param request_kwargs: 其它请求参数
|
2373
2373
|
|
2374
|
-
:return:
|
2374
|
+
:return: 迭代器,返回此目录内的(所有文件)文件信息
|
2375
2375
|
"""
|
2376
2376
|
suffix = suffix.strip(".")
|
2377
2377
|
if not (type or suffix):
|
@@ -2594,7 +2594,7 @@ def iter_files_with_path_skim(
|
|
2594
2594
|
:param async_: 是否异步
|
2595
2595
|
:param request_kwargs: 其它请求参数
|
2596
2596
|
|
2597
|
-
:return:
|
2597
|
+
:return: 迭代器,返回此目录内的(所有文件)文件信息
|
2598
2598
|
"""
|
2599
2599
|
from .download import iter_download_nodes
|
2600
2600
|
if isinstance(client, str):
|
@@ -3415,11 +3415,12 @@ def iter_nodes_using_info(
|
|
3415
3415
|
))
|
3416
3416
|
|
3417
3417
|
|
3418
|
+
# TODO: 是否能批量推送 "browse_audio" 或 "browse_video" 事件?
|
3418
3419
|
@overload
|
3419
|
-
def
|
3420
|
+
def iter_nodes_using_event(
|
3420
3421
|
client: str | P115Client,
|
3421
3422
|
ids: Iterable[int | str],
|
3422
|
-
|
3423
|
+
type: Literal["doc", "img"] = "img",
|
3423
3424
|
normalize_attr: None | bool | Callable[[dict], dict] = True,
|
3424
3425
|
id_to_dirnode: None | EllipsisType | MutableMapping[int, tuple[str, int] | DirNode] = None,
|
3425
3426
|
app: str = "android",
|
@@ -3430,10 +3431,10 @@ def iter_nodes_using_star_event(
|
|
3430
3431
|
) -> Iterator[dict]:
|
3431
3432
|
...
|
3432
3433
|
@overload
|
3433
|
-
def
|
3434
|
+
def iter_nodes_using_event(
|
3434
3435
|
client: str | P115Client,
|
3435
3436
|
ids: Iterable[int | str],
|
3436
|
-
|
3437
|
+
type: Literal["doc", "img"] = "img",
|
3437
3438
|
normalize_attr: None | bool | Callable[[dict], dict] = True,
|
3438
3439
|
id_to_dirnode: None | EllipsisType | MutableMapping[int, tuple[str, int] | DirNode] = None,
|
3439
3440
|
app: str = "android",
|
@@ -3443,10 +3444,10 @@ def iter_nodes_using_star_event(
|
|
3443
3444
|
**request_kwargs,
|
3444
3445
|
) -> AsyncIterator[dict]:
|
3445
3446
|
...
|
3446
|
-
def
|
3447
|
+
def iter_nodes_using_event(
|
3447
3448
|
client: str | P115Client,
|
3448
3449
|
ids: Iterable[int | str],
|
3449
|
-
|
3450
|
+
type: Literal["doc", "img"] = "img",
|
3450
3451
|
normalize_attr: None | bool | Callable[[dict], dict] = True,
|
3451
3452
|
id_to_dirnode: None | EllipsisType | MutableMapping[int, tuple[str, int] | DirNode] = None,
|
3452
3453
|
app: str = "android",
|
@@ -3455,14 +3456,18 @@ def iter_nodes_using_star_event(
|
|
3455
3456
|
async_: Literal[False, True] = False,
|
3456
3457
|
**request_kwargs,
|
3457
3458
|
) -> Iterator[dict] | AsyncIterator[dict]:
|
3458
|
-
"""
|
3459
|
+
"""通过先发送事件,然后收集这个事件,来获取一组 id 的信息
|
3459
3460
|
|
3460
|
-
..
|
3461
|
-
|
3461
|
+
.. note::
|
3462
|
+
如果未收集到事件,则说明文件 id 不存在或者已删除,你也可以因此找出所有的无效 id
|
3462
3463
|
|
3463
3464
|
:param client: 115 客户端或 cookies
|
3464
3465
|
:param ids: 一组文件或目录的 id 或 pickcode
|
3465
|
-
:param
|
3466
|
+
:param type: 事件类型
|
3467
|
+
|
3468
|
+
- "doc": 推送 "browse_document" 事件
|
3469
|
+
- "img": 推送 "browse_image" 事件
|
3470
|
+
|
3466
3471
|
:param normalize_attr: 把数据进行转换处理,使之便于阅读
|
3467
3472
|
:param id_to_dirnode: 字典,保存 id 到对应文件的 `DirNode(name, parent_id)` 命名元组的字典,如果为 ...,则忽略
|
3468
3473
|
:param app: 使用指定 app(设备)的接口
|
@@ -3492,42 +3497,38 @@ def iter_nodes_using_star_event(
|
|
3492
3497
|
client = P115Client(client, check_for_relogin=True)
|
3493
3498
|
if id_to_dirnode is None:
|
3494
3499
|
id_to_dirnode = ID_TO_DIRNODE_CACHE[client.user_id]
|
3500
|
+
if type == "doc":
|
3501
|
+
event_name = "browse_document"
|
3502
|
+
else:
|
3503
|
+
event_name = "browse_image"
|
3495
3504
|
def gen_step():
|
3496
3505
|
nonlocal ids
|
3497
3506
|
ts = int(time())
|
3498
3507
|
ids = set(map(to_id, ids))
|
3499
3508
|
yield life_show(client, async_=async_, **request_kwargs)
|
3500
|
-
yield
|
3509
|
+
yield post_event(
|
3510
|
+
client,
|
3511
|
+
ids,
|
3512
|
+
type=type,
|
3513
|
+
app=app,
|
3514
|
+
async_=async_,
|
3515
|
+
**request_kwargs,
|
3516
|
+
)
|
3501
3517
|
if app in ("", "web", "desktop", "harmony"):
|
3502
3518
|
get_base_url = cycle(("http://webapi.115.com", "https://webapi.115.com")).__next__
|
3503
3519
|
else:
|
3504
3520
|
get_base_url = cycle(("http://proapi.115.com", "https://proapi.115.com")).__next__
|
3505
3521
|
request_kwargs.setdefault("base_url", get_base_url)
|
3506
3522
|
discard = ids.discard
|
3507
|
-
|
3523
|
+
with with_iter_next(iter_life_behavior_once(
|
3508
3524
|
client,
|
3509
3525
|
from_time=ts,
|
3510
|
-
type=
|
3526
|
+
type=event_name,
|
3511
3527
|
app=app,
|
3512
3528
|
cooldown=cooldown,
|
3513
3529
|
async_=async_,
|
3514
3530
|
**request_kwargs,
|
3515
|
-
)
|
3516
|
-
if with_pics:
|
3517
|
-
it = chain(
|
3518
|
-
it,
|
3519
|
-
iter_life_behavior_once(
|
3520
|
-
client,
|
3521
|
-
from_time=ts,
|
3522
|
-
type="star_image_file",
|
3523
|
-
app=app,
|
3524
|
-
cooldown=cooldown,
|
3525
|
-
async_=async_,
|
3526
|
-
**request_kwargs,
|
3527
|
-
),
|
3528
|
-
async_=async_, # type: ignore
|
3529
|
-
)
|
3530
|
-
with with_iter_next(it) as get_next:
|
3531
|
+
)) as get_next:
|
3531
3532
|
while True:
|
3532
3533
|
event: dict = yield get_next()
|
3533
3534
|
fid = int(event["file_id"])
|
@@ -3807,7 +3808,7 @@ def iter_files_shortcut(
|
|
3807
3808
|
async_: Literal[False, True] = False,
|
3808
3809
|
**request_kwargs,
|
3809
3810
|
) -> Iterator[dict] | AsyncIterator[dict]:
|
3810
|
-
"""
|
3811
|
+
"""遍历目录树,获取(所有文件而非目录)文件信息(整合了多个函数的入口)
|
3811
3812
|
|
3812
3813
|
.. node::
|
3813
3814
|
`is_skim` 和 `with_path` 的不同取值组合,会决定采用不同的函数:
|
@@ -3938,10 +3939,11 @@ def iter_dupfiles[K](
|
|
3938
3939
|
|
3939
3940
|
|
3940
3941
|
@overload
|
3941
|
-
def
|
3942
|
+
def iter_media_files(
|
3942
3943
|
client: str | P115Client,
|
3943
|
-
cid: int = 0,
|
3944
|
+
cid: int | str = 0,
|
3944
3945
|
page_size: int = 8192,
|
3946
|
+
type: Literal[0, 1, 2, 3, 4, 5, 6, 7, 99] = 0,
|
3945
3947
|
order: Literal["file_name", "file_size", "file_type", "user_utime", "user_ptime", "user_otime"] = "user_ptime",
|
3946
3948
|
asc: Literal[0, 1] = 1,
|
3947
3949
|
cur: Literal[0, 1] = 0,
|
@@ -3952,10 +3954,11 @@ def iter_image_files(
|
|
3952
3954
|
) -> Iterator[dict]:
|
3953
3955
|
...
|
3954
3956
|
@overload
|
3955
|
-
def
|
3957
|
+
def iter_media_files(
|
3956
3958
|
client: str | P115Client,
|
3957
|
-
cid: int = 0,
|
3959
|
+
cid: int | str = 0,
|
3958
3960
|
page_size: int = 8192,
|
3961
|
+
type: Literal[0, 1, 2, 3, 4, 5, 6, 7, 99] = 0,
|
3959
3962
|
order: Literal["file_name", "file_size", "file_type", "user_utime", "user_ptime", "user_otime"] = "user_ptime",
|
3960
3963
|
asc: Literal[0, 1] = 1,
|
3961
3964
|
cur: Literal[0, 1] = 0,
|
@@ -3965,10 +3968,11 @@ def iter_image_files(
|
|
3965
3968
|
**request_kwargs,
|
3966
3969
|
) -> AsyncIterator[dict]:
|
3967
3970
|
...
|
3968
|
-
def
|
3971
|
+
def iter_media_files(
|
3969
3972
|
client: str | P115Client,
|
3970
|
-
cid: int = 0,
|
3973
|
+
cid: int | str = 0,
|
3971
3974
|
page_size: int = 8192,
|
3975
|
+
type: Literal[0, 1, 2, 3, 4, 5, 6, 7, 99] = 0,
|
3972
3976
|
order: Literal["file_name", "file_size", "file_type", "user_utime", "user_ptime", "user_otime"] = "user_ptime",
|
3973
3977
|
asc: Literal[0, 1] = 1,
|
3974
3978
|
cur: Literal[0, 1] = 0,
|
@@ -3977,14 +3981,26 @@ def iter_image_files(
|
|
3977
3981
|
async_: Literal[False, True] = False,
|
3978
3982
|
**request_kwargs,
|
3979
3983
|
) -> Iterator[dict] | AsyncIterator[dict]:
|
3980
|
-
"""
|
3984
|
+
"""遍历目录树,获取文件信息(如果是图片,则包含图片的 CDN 链接)
|
3981
3985
|
|
3982
3986
|
.. tip::
|
3983
|
-
这个函数的效果相当于 ``iter_files(client, cid, type=
|
3987
|
+
这个函数的效果相当于 ``iter_files(client, cid, type=type, ...)`` 所获取的文件列表,只是返回信息有些不同,速度似乎还是 ``iter_files`` 更快
|
3984
3988
|
|
3985
3989
|
:param client: 115 客户端或 cookies
|
3986
|
-
:param cid: 目录 id
|
3990
|
+
:param cid: 目录 id 或 pickcode
|
3987
3991
|
:param page_size: 分页大小
|
3992
|
+
:param type: 文件类型
|
3993
|
+
|
3994
|
+
- 0: 相当于 2,即获取图片,但用一个单独的接口
|
3995
|
+
- 1: 文档
|
3996
|
+
- 2: 图片
|
3997
|
+
- 3: 音频
|
3998
|
+
- 4: 视频
|
3999
|
+
- 5: 压缩包
|
4000
|
+
- 6: 应用
|
4001
|
+
- 7: 书籍
|
4002
|
+
- 99: 所有文件
|
4003
|
+
|
3988
4004
|
:param order: 排序
|
3989
4005
|
|
3990
4006
|
- "file_name": 文件名
|
@@ -4015,12 +4031,21 @@ def iter_image_files(
|
|
4015
4031
|
page_size = 8192
|
4016
4032
|
elif page_size < 16:
|
4017
4033
|
page_size = 16
|
4034
|
+
cid = to_id(cid)
|
4018
4035
|
payload = {"asc": asc, "cid": cid, "cur": cur, "limit": page_size, "o": order, "offset": 0}
|
4036
|
+
if type:
|
4037
|
+
fs_files = client.fs_files_media_app
|
4038
|
+
if type == 99:
|
4039
|
+
payload["type"] = -1
|
4040
|
+
else:
|
4041
|
+
payload["type"] = type
|
4042
|
+
else:
|
4043
|
+
fs_files = client.fs_files_image_app
|
4019
4044
|
def gen_step():
|
4020
4045
|
offset = 0
|
4021
4046
|
count = 0
|
4022
4047
|
while True:
|
4023
|
-
resp = yield
|
4048
|
+
resp = yield fs_files(payload, async_=async_, **request_kwargs)
|
4024
4049
|
check_response(resp)
|
4025
4050
|
if int(resp["cid"]) != cid:
|
4026
4051
|
raise FileNotFoundError(ENOENT, cid)
|
@@ -4107,7 +4132,7 @@ def search_iter(
|
|
4107
4132
|
- 5: 压缩包
|
4108
4133
|
- 6: 应用
|
4109
4134
|
- 7: 书籍
|
4110
|
-
- 99:
|
4135
|
+
- 99: 所有文件
|
4111
4136
|
|
4112
4137
|
:param offset: 开始索引,从 0 开始,要求 <= 10,000
|
4113
4138
|
:param page_size: 分页大小,要求 `offset + page_size <= 10,000`
|
@@ -4329,7 +4354,7 @@ def share_iter_files(
|
|
4329
4354
|
:param async_: 是否异步
|
4330
4355
|
:param request_kwargs: 其它请求参数
|
4331
4356
|
|
4332
|
-
:return:
|
4357
|
+
:return: 迭代器,返回此分享链接下的(所有文件)文件信息,由于接口返回信息有限,所以比较简略
|
4333
4358
|
|
4334
4359
|
.. code:: python
|
4335
4360
|
|
@@ -4460,7 +4485,7 @@ def share_search_iter(
|
|
4460
4485
|
- 5: 压缩包
|
4461
4486
|
- 6: 应用
|
4462
4487
|
- 7: 书籍
|
4463
|
-
- 99:
|
4488
|
+
- 99: 所有文件
|
4464
4489
|
|
4465
4490
|
:param offset: 开始索引,从 0 开始,要求 <= 10,000
|
4466
4491
|
:param page_size: 分页大小,要求 `offset + page_size <= 10,000`
|
@@ -4606,7 +4631,7 @@ def traverse_files(
|
|
4606
4631
|
- 5: 压缩包
|
4607
4632
|
- 6: 应用
|
4608
4633
|
- 7: 书籍
|
4609
|
-
- 99:
|
4634
|
+
- 99: 所有文件
|
4610
4635
|
|
4611
4636
|
:param auto_splitting_tasks: 是否根据统计信息自动拆分任务
|
4612
4637
|
:param auto_splitting_threshold: 如果 `auto_splitting_tasks` 为 True,且目录内的文件数大于 `auto_splitting_threshold`,则分拆此任务到它的各个直接子目录,否则批量拉取
|
@@ -4628,7 +4653,7 @@ def traverse_files(
|
|
4628
4653
|
:param async_: 是否异步
|
4629
4654
|
:param request_kwargs: 其它请求参数
|
4630
4655
|
|
4631
|
-
:return:
|
4656
|
+
:return: 迭代器,返回此目录内的(所有文件)文件信息
|
4632
4657
|
"""
|
4633
4658
|
suffix = suffix.strip(".")
|
4634
4659
|
if not (type or suffix):
|
@@ -1,19 +1,19 @@
|
|
1
1
|
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
2
2
|
p115client/__init__.py,sha256=1mx7njuAlqcuEWONTjSiiGnXyyNyqOcJyNX1FMHqQ-4,214
|
3
3
|
p115client/_upload.py,sha256=199Hc9B9vUMphDdwh8vK3yCIPusIfeAzzOLpC-WZ8C8,31184
|
4
|
-
p115client/client.py,sha256=
|
4
|
+
p115client/client.py,sha256=05ODXki0tes-WzRc6N6WT5zD8Lx_VWjV-yLIR8H6dxQ,809397
|
5
5
|
p115client/const.py,sha256=ZYtBtTFB0eljIR0tze21_52Gl0pQxvyqMmDwgB1bqNU,7803
|
6
6
|
p115client/exception.py,sha256=4SZ8ubOLMRxtcqc0u1kNzXqH1a6wwXJFwGnRDURoEgQ,3708
|
7
7
|
p115client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
p115client/tool/__init__.py,sha256=IwwzbCQ7jpRoFGTQUCfGBx8zvjqjgSFs98yKpYyI46s,429
|
9
9
|
p115client/tool/attr.py,sha256=G91V71EhsqIIPkhGDnv2z6nxVq7wgl6nNPDj3AKzw1I,3079
|
10
10
|
p115client/tool/auth.py,sha256=qlRcfEjzebseiHR2dyBpOoPpxB4k8P6Tj729S2TLB1s,1672
|
11
|
-
p115client/tool/download.py,sha256=
|
12
|
-
p115client/tool/edit.py,sha256=
|
11
|
+
p115client/tool/download.py,sha256=7F1HJ7Hfh2bu-aBpK7E3Ijhs5tqVgEBIByxpMNiNqxc,65397
|
12
|
+
p115client/tool/edit.py,sha256=Nqy8G_UCGbIUGG_udd3JM8073Sm9I0q3kUe4i3XcIOg,19640
|
13
13
|
p115client/tool/export_dir.py,sha256=jPD4VP0kbJ1MW9CDgUcInSmt0aJejhn257x30Sm3hss,23557
|
14
14
|
p115client/tool/fs_files.py,sha256=12ED23jAdQR0KvXSaVE3XOgOfEBVriMMJl4vbE2tR3E,15824
|
15
15
|
p115client/tool/history.py,sha256=9pgF9l8VvQkpjsVgtIzNcrUQZzLH9tt4JysBwJ4yHsk,11636
|
16
|
-
p115client/tool/iterdir.py,sha256=
|
16
|
+
p115client/tool/iterdir.py,sha256=qUlFc_fOGeKs3BrINCGwaoyBHkDopStPeKWXMYWBkP8,177884
|
17
17
|
p115client/tool/life.py,sha256=dfwm5jKfo0K9pIUZKpZ32oPBrlcfrezflSJyyDIbX8E,17721
|
18
18
|
p115client/tool/offline.py,sha256=6HaGkbsAAx3FPFvSr_7LZvrUw_fp3QRB2y2kVRHNgZ0,6291
|
19
19
|
p115client/tool/pool.py,sha256=PImYG4fU7retZVFDPYib9e87J3RvJvugOW1mxX9jSU0,13831
|
@@ -22,7 +22,7 @@ p115client/tool/upload.py,sha256=dpww3TGSOyjqz1EogQEJDiZ9QWERd47izZOw9mNCCiA,329
|
|
22
22
|
p115client/tool/util.py,sha256=gvA-o-TcEAR3o754Kn82Bu6yggmnAhScUCrRpMVCI50,3934
|
23
23
|
p115client/tool/xys.py,sha256=r9wzE5VgpR6ATYHM1uVZ06uIU4qqVeDyRTYU6W_N_Tc,10190
|
24
24
|
p115client/type.py,sha256=h_pGKTlz07g64Y_93ylF-fUyC8g-HiQacMhu4KOXjYA,6457
|
25
|
-
p115client-0.0.5.
|
26
|
-
p115client-0.0.5.
|
27
|
-
p115client-0.0.5.
|
28
|
-
p115client-0.0.5.
|
25
|
+
p115client-0.0.5.15.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
26
|
+
p115client-0.0.5.15.1.dist-info/METADATA,sha256=u70e2JlJ_fR0W1tIFFfa4iHUwPJzciy0hMzRpEl6zhQ,8230
|
27
|
+
p115client-0.0.5.15.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
28
|
+
p115client-0.0.5.15.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|