p123client 0.0.6.1__py3-none-any.whl → 0.0.6.3__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.
- p123client/client.py +48 -16
- p123client/exception.py +12 -1
- p123client/tool/__init__.py +1 -1
- {p123client-0.0.6.1.dist-info → p123client-0.0.6.3.dist-info}/METADATA +3 -3
- p123client-0.0.6.3.dist-info/RECORD +12 -0
- p123client-0.0.6.1.dist-info/RECORD +0 -12
- {p123client-0.0.6.1.dist-info → p123client-0.0.6.3.dist-info}/LICENSE +0 -0
- {p123client-0.0.6.1.dist-info → p123client-0.0.6.3.dist-info}/WHEEL +0 -0
p123client/client.py
CHANGED
@@ -107,6 +107,20 @@ def dict_to_lower_merge[K, V](
|
|
107
107
|
return m
|
108
108
|
|
109
109
|
|
110
|
+
def update_headers_in_kwargs(
|
111
|
+
request_kwargs: dict,
|
112
|
+
/,
|
113
|
+
*args,
|
114
|
+
**kwargs,
|
115
|
+
):
|
116
|
+
if headers := request_kwargs.get("headers"):
|
117
|
+
headers = dict(headers)
|
118
|
+
else:
|
119
|
+
headers = {}
|
120
|
+
headers.update(*args, **kwargs)
|
121
|
+
request_kwargs["headers"] = headers
|
122
|
+
|
123
|
+
|
110
124
|
def escape_filename(
|
111
125
|
s: str,
|
112
126
|
/,
|
@@ -742,6 +756,22 @@ class P123OpenClient:
|
|
742
756
|
|
743
757
|
:payload:
|
744
758
|
- fileID: int 💡 文件 id
|
759
|
+
|
760
|
+
:return:
|
761
|
+
响应数据的 data 字段是一个字典,键值如下:
|
762
|
+
|
763
|
+
+---------------------+--------+----------+--------------------------------------------------------------+
|
764
|
+
| 名称 | 类型 | 是否必填 | 说明 |
|
765
|
+
+=====================+========+==========+==============================================================+
|
766
|
+
| list | array | 必填 | 响应列表 |
|
767
|
+
+---------------------+--------+----------+--------------------------------------------------------------|
|
768
|
+
| list[*].resolutions | string | 必填 | 分辨率 |
|
769
|
+
+---------------------+--------+----------+--------------------------------------------------------------|
|
770
|
+
| list[*].address | string | 必填 | 播放地址。请将播放地址放入支持的 hls 协议的播放器中进行播放。|
|
771
|
+
| | | | 示例在线播放地址: https://m3u8-player.com/ |
|
772
|
+
| | | | 请注意:转码链接播放过程中将会消耗您的直链流量。 |
|
773
|
+
| | | | 如果您开启了直链鉴权,也需要将转码链接根据鉴权指引进行签名。 |
|
774
|
+
+---------------------+--------+----------+--------------------------------------------------------------+
|
745
775
|
"""
|
746
776
|
api = complete_url("/api/v1/direct-link/get/m3u8", base_url)
|
747
777
|
if not isinstance(payload, dict):
|
@@ -832,6 +862,17 @@ class P123OpenClient:
|
|
832
862
|
|
833
863
|
:payload:
|
834
864
|
- ids: str 💡 视频文件 id 列表
|
865
|
+
|
866
|
+
:return:
|
867
|
+
响应数据的 data 字段是一个字典,键值如下:
|
868
|
+
|
869
|
+
+-----------+-------+----------+-------------------------------------------+
|
870
|
+
| 名称 | 类型 | 是否必填 | 说明 |
|
871
|
+
+===========+=======+==========+===========================================+
|
872
|
+
| noneList | array | 必填 | 未发起过转码的 ID |
|
873
|
+
| errorList | array | 必填 | 错误文件ID列表,这些文件ID无法进行转码操作 |
|
874
|
+
| success | array | 必填 | 转码成功的文件ID列表 |
|
875
|
+
+-----------+-------+----------+-------------------------------------------+
|
835
876
|
"""
|
836
877
|
api = complete_url("/api/v1/direct-link/queryTranscode", base_url)
|
837
878
|
if not isinstance(payload, dict):
|
@@ -934,6 +975,7 @@ class P123OpenClient:
|
|
934
975
|
- fileId: int 💡 文件 id
|
935
976
|
"""
|
936
977
|
api = complete_url("/api/v1/file/download_info", base_url)
|
978
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
937
979
|
if not isinstance(payload, dict):
|
938
980
|
payload = {"fileId": payload}
|
939
981
|
return self.request(api, params=payload, async_=async_, **request_kwargs)
|
@@ -2296,8 +2338,8 @@ class P123OpenClient:
|
|
2296
2338
|
"""
|
2297
2339
|
api = complete_url("/upload/v1/oss/file/create", base_url)
|
2298
2340
|
payload = dict_to_lower_merge(payload, type=1)
|
2299
|
-
if not payload
|
2300
|
-
payload
|
2341
|
+
if "duplicate" in payload and not payload["duplicate"]:
|
2342
|
+
del payload["duplicate"]
|
2301
2343
|
return self.request(api, "POST", json=payload, async_=async_, **request_kwargs)
|
2302
2344
|
|
2303
2345
|
@overload
|
@@ -3642,8 +3684,8 @@ class P123OpenClient:
|
|
3642
3684
|
"parentFileId": 0,
|
3643
3685
|
"containDir": "false",
|
3644
3686
|
})
|
3645
|
-
if not payload
|
3646
|
-
payload
|
3687
|
+
if "duplicate" in payload and not payload["duplicate"]:
|
3688
|
+
del payload["duplicate"]
|
3647
3689
|
return self.request(api, "POST", json=payload, async_=async_, **request_kwargs)
|
3648
3690
|
|
3649
3691
|
@overload
|
@@ -4479,12 +4521,7 @@ class P123Client(P123OpenClient):
|
|
4479
4521
|
"""
|
4480
4522
|
def gen_step():
|
4481
4523
|
nonlocal payload
|
4482
|
-
|
4483
|
-
headers = dict(headers)
|
4484
|
-
else:
|
4485
|
-
headers = {}
|
4486
|
-
headers["platform"] = "android"
|
4487
|
-
request_kwargs["headers"] = headers
|
4524
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
4488
4525
|
if not isinstance(payload, dict):
|
4489
4526
|
resp = yield self.fs_info(
|
4490
4527
|
payload,
|
@@ -5877,12 +5914,7 @@ class P123Client(P123OpenClient):
|
|
5877
5914
|
payload = self
|
5878
5915
|
self = None
|
5879
5916
|
assert payload is not None
|
5880
|
-
|
5881
|
-
headers = dict(headers)
|
5882
|
-
else:
|
5883
|
-
headers = {}
|
5884
|
-
headers["platform"] = "android"
|
5885
|
-
request_kwargs["headers"] = headers
|
5917
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
5886
5918
|
api = complete_url("share/download/info", base_url)
|
5887
5919
|
if self is None:
|
5888
5920
|
request_kwargs.setdefault("parse", default_parse)
|
p123client/exception.py
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
__all__ = [
|
4
|
+
__all__ = [
|
5
|
+
"P123Warning", "P123OSError", "P123BrokenUpload",
|
6
|
+
"P123AccessTokenError", "P123AuthenticationError",
|
7
|
+
]
|
5
8
|
|
6
9
|
import warnings
|
7
10
|
|
@@ -47,3 +50,11 @@ class P123OSError(OSError):
|
|
47
50
|
class P123BrokenUpload(P123OSError):
|
48
51
|
pass
|
49
52
|
|
53
|
+
|
54
|
+
class P123AccessTokenError(P123OSError):
|
55
|
+
pass
|
56
|
+
|
57
|
+
|
58
|
+
class P123AuthenticationError(P123OSError):
|
59
|
+
pass
|
60
|
+
|
p123client/tool/__init__.py
CHANGED
@@ -280,7 +280,7 @@ def _iterdir(
|
|
280
280
|
:return: 迭代器,产生文件或目录的信息
|
281
281
|
"""
|
282
282
|
default_payload = payload
|
283
|
-
page_size = int(payload
|
283
|
+
page_size = int(payload.setdefault("limit", 100))
|
284
284
|
def gen_step():
|
285
285
|
nonlocal parent_id
|
286
286
|
dq: deque[tuple[int, int, str]] = deque()
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p123client
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.3
|
4
4
|
Summary: Python 123 webdisk client.
|
5
|
-
Home-page: https://github.com/ChenyangGao/
|
5
|
+
Home-page: https://github.com/ChenyangGao/p123client
|
6
6
|
License: MIT
|
7
7
|
Keywords: 123,webdisk,client
|
8
8
|
Author: ChenyangGao
|
@@ -34,7 +34,7 @@ Requires-Dist: python-httpfile (>=0.0.5)
|
|
34
34
|
Requires-Dist: python-iterutils (>=0.2)
|
35
35
|
Requires-Dist: python-property (>=0.0.3)
|
36
36
|
Requires-Dist: yarl
|
37
|
-
Project-URL: Repository, https://github.com/ChenyangGao/
|
37
|
+
Project-URL: Repository, https://github.com/ChenyangGao/p123client
|
38
38
|
Description-Content-Type: text/markdown
|
39
39
|
|
40
40
|
# Python 123 网盘客户端
|
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
2
|
+
p123client/__init__.py,sha256=gfUum-q3f_XuXOk2HpArDAIxAlscZm8Fau1kiNkNFpg,214
|
3
|
+
p123client/client.py,sha256=E4X5qEKnkDb17KGiy7CrhzKBkQ8ukFTFM6qxUzGsnVg,246781
|
4
|
+
p123client/const.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
5
|
+
p123client/exception.py,sha256=020xGo8WQmGCJz1UzNg9oFzpEvToQcgTye0s6lkFASQ,1540
|
6
|
+
p123client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
+
p123client/tool/__init__.py,sha256=2k_tcc67O9QG4wzESIdnAwqNHybCGlrsnxo_uBqBhEI,16673
|
8
|
+
p123client/type.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
9
|
+
p123client-0.0.6.3.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
10
|
+
p123client-0.0.6.3.dist-info/METADATA,sha256=MgwA-g5ZGjXIchhxrFkYLPIoPeVJU96399yiIkxlBPw,8855
|
11
|
+
p123client-0.0.6.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
+
p123client-0.0.6.3.dist-info/RECORD,,
|
@@ -1,12 +0,0 @@
|
|
1
|
-
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
2
|
-
p123client/__init__.py,sha256=gfUum-q3f_XuXOk2HpArDAIxAlscZm8Fau1kiNkNFpg,214
|
3
|
-
p123client/client.py,sha256=T0PcrNCgbFBRIoFXt6iVYjDCS2FSStadAeaFwb_q-hw,244302
|
4
|
-
p123client/const.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
5
|
-
p123client/exception.py,sha256=d2PN6mRJuw6SXNiTOBfjZQ6qfInAvkERkcbx4PQ-7vA,1369
|
6
|
-
p123client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
p123client/tool/__init__.py,sha256=P67eusj4p7O6VyOgRrSJEspI3nTM7mLFySyw55bsOtA,16657
|
8
|
-
p123client/type.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
9
|
-
p123client-0.0.6.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
10
|
-
p123client-0.0.6.1.dist-info/METADATA,sha256=2aec3rDPgFBC4UI1QErD4RBR7W76VvblXCZsuELbjlk,8869
|
11
|
-
p123client-0.0.6.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
-
p123client-0.0.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|