p115client 0.0.5.8.4__py3-none-any.whl → 0.0.5.8.5__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 CHANGED
@@ -3139,6 +3139,64 @@ class P115OpenClient(ClientRequestMixin):
3139
3139
  }
3140
3140
  return self.request(url=api, params=payload, async_=async_, **request_kwargs)
3141
3141
 
3142
+ @overload
3143
+ def fs_star_set(
3144
+ self,
3145
+ payload: int | str | Iterable[int | str] | dict,
3146
+ /,
3147
+ star: bool = True,
3148
+ base_url: bool | str | Callable[[], str] = False,
3149
+ *,
3150
+ async_: Literal[False] = False,
3151
+ **request_kwargs,
3152
+ ) -> dict:
3153
+ ...
3154
+ @overload
3155
+ def fs_star_set(
3156
+ self,
3157
+ payload: int | str | Iterable[int | str] | dict,
3158
+ /,
3159
+ star: bool = True,
3160
+ base_url: bool | str | Callable[[], str] = False,
3161
+ *,
3162
+ async_: Literal[True],
3163
+ **request_kwargs,
3164
+ ) -> Coroutine[Any, Any, dict]:
3165
+ ...
3166
+ def fs_star_set(
3167
+ self,
3168
+ payload: int | str | Iterable[int | str] | dict,
3169
+ /,
3170
+ star: bool = True,
3171
+ base_url: bool | str | Callable[[], str] = False,
3172
+ *,
3173
+ async_: Literal[False, True] = False,
3174
+ **request_kwargs,
3175
+ ) -> dict | Coroutine[Any, Any, dict]:
3176
+ """为文件或目录设置或取消星标,此接口是对 `fs_update_open` 的封装
3177
+
3178
+ .. note::
3179
+ 即使其中任何一个 id 目前已经被删除,也可以操作成功
3180
+
3181
+ :payload:
3182
+ - file_id: int | str 💡 只能传入 1 个
3183
+ - file_id[0]: int | str 💡 如果有多个,则按顺序给出
3184
+ - file_id[1]: int | str
3185
+ - ...
3186
+ - star: 0 | 1 = 1
3187
+ """
3188
+ api = complete_webapi("/files/star", base_url=base_url)
3189
+ if isinstance(payload, (int, str)):
3190
+ payload = {"file_id": payload, "star": int(star)}
3191
+ elif not isinstance(payload, dict):
3192
+ payload = {f"file_id[{i}]": id for i, id in enumerate(payload)}
3193
+ if not payload:
3194
+ return {"state": False, "message": "no op"}
3195
+ payload["star"] = int(star)
3196
+ else:
3197
+ payload = {"star": int(star), **payload}
3198
+ return self.fs_update(payload, async_=async_, **request_kwargs)
3199
+
3142
3200
  @overload
3143
3201
  def fs_update(
3144
3202
  self,
@@ -3175,13 +3233,16 @@ class P115OpenClient(ClientRequestMixin):
3175
3233
  POST https://proapi.115.com/open/ufile/update
3176
3234
 
3177
3235
  .. hint::
3178
- 类似于 `P115Client.fs_edit_app`
3236
+ 即使文件已经被删除,也可以操作成功
3179
3237
 
3180
3238
  .. note::
3181
3239
  https://www.yuque.com/115yun/open/gyrpw5a0zc4sengm
3182
3240
 
3183
3241
  :payload:
3184
- - file_id: int | str
3242
+ - file_id: int | str 💡 只能传入 1 个
3243
+ - file_id[0]: int | str 💡 如果有多个,则按顺序给出
3244
+ - file_id[1]: int | str
3245
+ - ...
3185
3246
  - file_name: str = <default> 💡 文件名
3186
3247
  - star: 0 | 1 = <default> 💡 是否星标:0:取消星标 1:设置星标
3187
3248
  - ...
@@ -3970,6 +4031,7 @@ class P115OpenClient(ClientRequestMixin):
3970
4031
  fs_mkdir_open = fs_mkdir
3971
4032
  fs_move_open = fs_move
3972
4033
  fs_search_open = fs_search
4034
+ fs_star_set_open = fs_star_set
3973
4035
  fs_update_open = fs_update
3974
4036
  recyclebin_clean_open = recyclebin_clean
3975
4037
  recyclebin_list_open = recyclebin_list
p115client/tool/edit.py CHANGED
@@ -103,6 +103,7 @@ def update_desc(
103
103
  desc: str = "",
104
104
  batch_size: int = 10_000,
105
105
  max_workers: None | int = None,
106
+ app: str = "web",
106
107
  *,
107
108
  async_: Literal[False] = False,
108
109
  **request_kwargs,
@@ -116,6 +117,7 @@ def update_desc(
116
117
  desc: str = "",
117
118
  batch_size: int = 10_000,
118
119
  max_workers: None | int = None,
120
+ app: str = "web",
119
121
  *,
120
122
  async_: Literal[True],
121
123
  **request_kwargs,
@@ -128,6 +130,7 @@ def update_desc(
128
130
  desc: str = "",
129
131
  batch_size: int = 10_000,
130
132
  max_workers: None | int = None,
133
+ app: str = "web",
131
134
  *,
132
135
  async_: Literal[False, True] = False,
133
136
  **request_kwargs,
@@ -139,13 +142,19 @@ def update_desc(
139
142
  :param desc: 备注文本
140
143
  :param batch_size: 批次大小,分批次,每次提交的 id 数
141
144
  :param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
145
+ :param app: 使用此设备的接口
142
146
  :param async_: 是否异步
143
147
  :param request_kwargs: 其它请求参数
144
148
  """
149
+ if app in ("", "web", "desktop", "harmony"):
150
+ method = "fs_desc_set"
151
+ else:
152
+ method = "fs_desc_set_app"
153
+ request_kwargs["app"] = app
145
154
  return update_abstract(
146
155
  client,
147
156
  ids, # type: ignore
148
- method="fs_desc_set",
157
+ method=method,
149
158
  value=desc,
150
159
  batch_size=batch_size,
151
160
  max_workers=max_workers,
@@ -162,6 +171,7 @@ def update_star(
162
171
  star: bool = True,
163
172
  batch_size: int = 10_000,
164
173
  max_workers: None | int = None,
174
+ app: str = "web",
165
175
  *,
166
176
  async_: Literal[False] = False,
167
177
  **request_kwargs,
@@ -175,6 +185,7 @@ def update_star(
175
185
  star: bool = True,
176
186
  batch_size: int = 10_000,
177
187
  max_workers: None | int = None,
188
+ app: str = "web",
178
189
  *,
179
190
  async_: Literal[True],
180
191
  **request_kwargs,
@@ -187,6 +198,7 @@ def update_star(
187
198
  star: bool = True,
188
199
  batch_size: int = 10_000,
189
200
  max_workers: None | int = None,
201
+ app: str = "web",
190
202
  *,
191
203
  async_: Literal[False, True] = False,
192
204
  **request_kwargs,
@@ -201,13 +213,23 @@ def update_star(
201
213
  :param star: 是否设置星标
202
214
  :param batch_size: 批次大小,分批次,每次提交的 id 数
203
215
  :param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
216
+ :param app: 使用此设备的接口
204
217
  :param async_: 是否异步
205
218
  :param request_kwargs: 其它请求参数
206
219
  """
220
+ if isinstance(client, str):
221
+ client = P115Client(client, check_for_relogin=True)
222
+ if not isinstance(client, P115Client) or app == "open":
223
+ method = "fs_star_set_open"
224
+ elif app in ("", "web", "desktop", "harmony"):
225
+ method = "fs_star_set"
226
+ else:
227
+ method = "fs_star_set_app"
228
+ request_kwargs["app"] = app
207
229
  return update_abstract(
208
230
  client,
209
231
  ids, # type: ignore
210
- method="fs_star_set",
232
+ method=method,
211
233
  value=star,
212
234
  batch_size=batch_size,
213
235
  max_workers=max_workers,
@@ -224,6 +246,7 @@ def update_label(
224
246
  label: int | str = 1,
225
247
  batch_size: int = 10_000,
226
248
  max_workers: None | int = None,
249
+ app: str = "web",
227
250
  *,
228
251
  async_: Literal[False] = False,
229
252
  **request_kwargs,
@@ -237,6 +260,7 @@ def update_label(
237
260
  label: int | str = 1,
238
261
  batch_size: int = 10_000,
239
262
  max_workers: None | int = None,
263
+ app: str = "web",
240
264
  *,
241
265
  async_: Literal[True],
242
266
  **request_kwargs,
@@ -249,6 +273,7 @@ def update_label(
249
273
  label: int | str = 1,
250
274
  batch_size: int = 10_000,
251
275
  max_workers: None | int = None,
276
+ app: str = "web",
252
277
  *,
253
278
  async_: Literal[False, True] = False,
254
279
  **request_kwargs,
@@ -260,13 +285,19 @@ def update_label(
260
285
  :param label: 标签 id,多个用逗号 "," 隔开,如果用一个根本不存在的 id,效果就是清空标签列表
261
286
  :param batch_size: 批次大小,分批次,每次提交的 id 数
262
287
  :param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
288
+ :param app: 使用此设备的接口
263
289
  :param async_: 是否异步
264
290
  :param request_kwargs: 其它请求参数
265
291
  """
292
+ if app in ("", "web", "desktop", "harmony"):
293
+ method = "fs_label_set"
294
+ else:
295
+ method = "fs_label_set_app"
296
+ request_kwargs["app"] = app
266
297
  return update_abstract(
267
298
  client,
268
299
  ids, # type: ignore
269
- method="fs_label_set",
300
+ method=method,
270
301
  value=label,
271
302
  batch_size=batch_size,
272
303
  max_workers=max_workers,
@@ -401,6 +432,7 @@ def update_show_play_long(
401
432
  show: bool = True,
402
433
  batch_size: int = 10_000,
403
434
  max_workers: None | int = None,
435
+ app: str = "web",
404
436
  *,
405
437
  async_: Literal[False] = False,
406
438
  **request_kwargs,
@@ -414,6 +446,7 @@ def update_show_play_long(
414
446
  show: bool = True,
415
447
  batch_size: int = 10_000,
416
448
  max_workers: None | int = None,
449
+ app: str = "web",
417
450
  *,
418
451
  async_: Literal[True],
419
452
  **request_kwargs,
@@ -426,6 +459,7 @@ def update_show_play_long(
426
459
  show: bool = True,
427
460
  batch_size: int = 10_000,
428
461
  max_workers: None | int = None,
462
+ app: str = "web",
429
463
  *,
430
464
  async_: Literal[False, True] = False,
431
465
  **request_kwargs,
@@ -437,13 +471,19 @@ def update_show_play_long(
437
471
  :param show: 是否显示时长
438
472
  :param batch_size: 批次大小,分批次,每次提交的 id 数
439
473
  :param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
474
+ :param app: 使用此设备的接口
440
475
  :param async_: 是否异步
441
476
  :param request_kwargs: 其它请求参数
442
477
  """
478
+ if app in ("", "web", "desktop", "harmony"):
479
+ method = "fs_show_play_long_set"
480
+ else:
481
+ method = "fs_show_play_long_set_app"
482
+ request_kwargs["app"] = app
443
483
  return update_abstract(
444
484
  client,
445
485
  ids, # type: ignore
446
- method="fs_show_play_long_set",
486
+ method=method,
447
487
  value=show,
448
488
  batch_size=batch_size,
449
489
  max_workers=max_workers,
@@ -518,6 +558,7 @@ def batch_unstar(
518
558
  batch_size: int = 10_000,
519
559
  ensure_file: None | bool = None,
520
560
  max_workers: None | int = None,
561
+ app: str = "web",
521
562
  *,
522
563
  async_: Literal[False] = False,
523
564
  **request_kwargs,
@@ -530,6 +571,7 @@ def batch_unstar(
530
571
  batch_size: int = 10_000,
531
572
  ensure_file: None | bool = None,
532
573
  max_workers: None | int = None,
574
+ app: str = "web",
533
575
  *,
534
576
  async_: Literal[True],
535
577
  **request_kwargs,
@@ -541,6 +583,7 @@ def batch_unstar(
541
583
  batch_size: int = 10_000,
542
584
  ensure_file: None | bool = None,
543
585
  max_workers: None | int = None,
586
+ app: str = "web",
544
587
  *,
545
588
  async_: Literal[False, True] = False,
546
589
  **request_kwargs,
@@ -556,6 +599,7 @@ def batch_unstar(
556
599
  - None: 可以是目录或文件
557
600
 
558
601
  :param max_workers: 并发工作数,如果为 None 或者 <= 0,则自动确定
602
+ :param app: 使用此设备的接口
559
603
  :param async_: 是否异步
560
604
  :param request_kwargs: 其它请求参数
561
605
  """
@@ -572,7 +616,7 @@ def batch_unstar(
572
616
  client,
573
617
  payload={"cid": 0, "count_folders": 1, "cur": 0, "fc_mix": 0, "offset": 0, "show_dir": 1, "star": 1},
574
618
  ensure_file=ensure_file,
575
- app="android",
619
+ app=app,
576
620
  cooldown=0.5,
577
621
  async_=async_,
578
622
  **request_kwargs,
@@ -587,6 +631,7 @@ def batch_unstar(
587
631
  star=False,
588
632
  batch_size=batch_size,
589
633
  max_workers=max_workers,
634
+ app=app,
590
635
  async_=async_, # type: ignore
591
636
  **request_kwargs,
592
637
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: p115client
3
- Version: 0.0.5.8.4
3
+ Version: 0.0.5.8.5
4
4
  Summary: Python 115 webdisk client.
5
5
  Home-page: https://github.com/ChenyangGao/p115client
6
6
  License: MIT
@@ -1,13 +1,13 @@
1
1
  LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
2
  p115client/__init__.py,sha256=1mx7njuAlqcuEWONTjSiiGnXyyNyqOcJyNX1FMHqQ-4,214
3
3
  p115client/_upload.py,sha256=DOckFLU_P7Fl0BNu_0-2od6pPsCnzroYY6zZE5_EMnM,30735
4
- p115client/client.py,sha256=KaW5HweTu2tlHI54cR_GBhx5ga3encV4Vn9pox1eUhI,715167
4
+ p115client/client.py,sha256=PvlnygUvcLrLrZF9fYWt3NIg2ayMWee6Iw4f-v78S8Y,717352
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
8
8
  p115client/tool/__init__.py,sha256=2YrKoAcFYOuqu2nUBoPVhxMOseAvcLE_LcnbZV11UKw,324
9
9
  p115client/tool/download.py,sha256=7eRZw7zuN6V7UhScm-TRZmR3m_wC4TBckod0IHxW6LU,60840
10
- p115client/tool/edit.py,sha256=VtJq3IU1iSLxzlzrdUcjkPlaDXW3c2s5x2pSym78tG8,16406
10
+ p115client/tool/edit.py,sha256=3hQ5J3hHQx4yNsGcWSechBYAvZRSQUxfXLXuqXiDKmk,17789
11
11
  p115client/tool/export_dir.py,sha256=iMnKtnESi8HKvW9WhIvOdEoMXSBpAnhFlGeyKXHpQbE,24545
12
12
  p115client/tool/fs_files.py,sha256=hkezLKrtTAGPDkPxwq6jMrm8s2-unHZQBR7cDvh41qs,16027
13
13
  p115client/tool/iterdir.py,sha256=U7N_clidyoFfhRK5f8R_9MRjP5BEK7xBqezCw7bxOeQ,184109
@@ -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=n89n9OLBXx6t20L61wJgfrP6V4jW3sHgyaQNBLdUwUQ,3578
19
19
  p115client/type.py,sha256=e4g9URQBE23XN2dGomldj8wC6NlDWBBSVC5Bmd8giBc,5993
20
- p115client-0.0.5.8.4.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
21
- p115client-0.0.5.8.4.dist-info/METADATA,sha256=bv24ktwrCmDEootVJrCMdWbpFuPukjS0sac-0bG_UYM,8233
22
- p115client-0.0.5.8.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
23
- p115client-0.0.5.8.4.dist-info/RECORD,,
20
+ p115client-0.0.5.8.5.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
21
+ p115client-0.0.5.8.5.dist-info/METADATA,sha256=G8aLCfnwfzwODda-MyneCwCs5If95EeK1IIwdBkIO54,8233
22
+ p115client-0.0.5.8.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
23
+ p115client-0.0.5.8.5.dist-info/RECORD,,