p123client 0.0.6.2__py3-none-any.whl → 0.0.6.4__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 +78 -12
- {p123client-0.0.6.2.dist-info → p123client-0.0.6.4.dist-info}/METADATA +3 -3
- {p123client-0.0.6.2.dist-info → p123client-0.0.6.4.dist-info}/RECORD +5 -5
- {p123client-0.0.6.2.dist-info → p123client-0.0.6.4.dist-info}/LICENSE +0 -0
- {p123client-0.0.6.2.dist-info → p123client-0.0.6.4.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
|
/,
|
@@ -961,6 +975,7 @@ class P123OpenClient:
|
|
961
975
|
- fileId: int 💡 文件 id
|
962
976
|
"""
|
963
977
|
api = complete_url("/api/v1/file/download_info", base_url)
|
978
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
964
979
|
if not isinstance(payload, dict):
|
965
980
|
payload = {"fileId": payload}
|
966
981
|
return self.request(api, params=payload, async_=async_, **request_kwargs)
|
@@ -4506,12 +4521,7 @@ class P123Client(P123OpenClient):
|
|
4506
4521
|
"""
|
4507
4522
|
def gen_step():
|
4508
4523
|
nonlocal payload
|
4509
|
-
|
4510
|
-
headers = dict(headers)
|
4511
|
-
else:
|
4512
|
-
headers = {}
|
4513
|
-
headers["platform"] = "android"
|
4514
|
-
request_kwargs["headers"] = headers
|
4524
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
4515
4525
|
if not isinstance(payload, dict):
|
4516
4526
|
resp = yield self.fs_info(
|
4517
4527
|
payload,
|
@@ -4601,6 +4611,67 @@ class P123Client(P123OpenClient):
|
|
4601
4611
|
**request_kwargs,
|
4602
4612
|
)
|
4603
4613
|
|
4614
|
+
@overload
|
4615
|
+
def download_url(
|
4616
|
+
self,
|
4617
|
+
payload: dict | int | str,
|
4618
|
+
/,
|
4619
|
+
*,
|
4620
|
+
async_: Literal[False] = False,
|
4621
|
+
**request_kwargs,
|
4622
|
+
) -> str:
|
4623
|
+
...
|
4624
|
+
@overload
|
4625
|
+
def download_url(
|
4626
|
+
self,
|
4627
|
+
payload: dict | int | str,
|
4628
|
+
/,
|
4629
|
+
*,
|
4630
|
+
async_: Literal[True],
|
4631
|
+
**request_kwargs,
|
4632
|
+
) -> Coroutine[Any, Any, str]:
|
4633
|
+
...
|
4634
|
+
def download_url(
|
4635
|
+
self,
|
4636
|
+
payload: dict | int | str,
|
4637
|
+
/,
|
4638
|
+
*,
|
4639
|
+
async_: Literal[False, True] = False,
|
4640
|
+
**request_kwargs,
|
4641
|
+
) -> str | Coroutine[Any, Any, str]:
|
4642
|
+
"""获取下载链接
|
4643
|
+
|
4644
|
+
:params payload: 文件 id 或者文件信息,文件信息必须包含的信息如下:
|
4645
|
+
|
4646
|
+
- S3KeyFlag: str 💡 存储桶名
|
4647
|
+
- Etag: str 💡 文件的 MD5 散列值
|
4648
|
+
- Size: int 💡 文件大小
|
4649
|
+
- FileName: str = <default> 💡 默认用 Etag(即 MD5)作为文件名
|
4650
|
+
|
4651
|
+
:params async_: 是否异步
|
4652
|
+
:params request_kwargs: 其它请求参数
|
4653
|
+
|
4654
|
+
:return: 下载链接
|
4655
|
+
"""
|
4656
|
+
def gen_step():
|
4657
|
+
if isinstance(payload, dict):
|
4658
|
+
resp = yield self.download_info(
|
4659
|
+
payload,
|
4660
|
+
async_=async_,
|
4661
|
+
**request_kwargs,
|
4662
|
+
)
|
4663
|
+
check_response(resp)
|
4664
|
+
return resp["data"]["DownloadUrl"]
|
4665
|
+
else:
|
4666
|
+
resp = yield self.download_info_open(
|
4667
|
+
payload,
|
4668
|
+
async_=async_,
|
4669
|
+
**request_kwargs,
|
4670
|
+
)
|
4671
|
+
check_response(resp)
|
4672
|
+
return resp["data"]["downloadUrl"]
|
4673
|
+
return run_gen_step(gen_step, async_=async_)
|
4674
|
+
|
4604
4675
|
@overload
|
4605
4676
|
def fs_copy(
|
4606
4677
|
self,
|
@@ -5904,12 +5975,7 @@ class P123Client(P123OpenClient):
|
|
5904
5975
|
payload = self
|
5905
5976
|
self = None
|
5906
5977
|
assert payload is not None
|
5907
|
-
|
5908
|
-
headers = dict(headers)
|
5909
|
-
else:
|
5910
|
-
headers = {}
|
5911
|
-
headers["platform"] = "android"
|
5912
|
-
request_kwargs["headers"] = headers
|
5978
|
+
update_headers_in_kwargs(request_kwargs, platform="android")
|
5913
5979
|
api = complete_url("share/download/info", base_url)
|
5914
5980
|
if self is None:
|
5915
5981
|
request_kwargs.setdefault("parse", default_parse)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: p123client
|
3
|
-
Version: 0.0.6.
|
3
|
+
Version: 0.0.6.4
|
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 网盘客户端
|
@@ -1,12 +1,12 @@
|
|
1
1
|
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
2
2
|
p123client/__init__.py,sha256=gfUum-q3f_XuXOk2HpArDAIxAlscZm8Fau1kiNkNFpg,214
|
3
|
-
p123client/client.py,sha256=
|
3
|
+
p123client/client.py,sha256=Ha09EnH9tC2CfacGH7DaO93BUVB6wRDiSym32In2WFw,248614
|
4
4
|
p123client/const.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
5
5
|
p123client/exception.py,sha256=020xGo8WQmGCJz1UzNg9oFzpEvToQcgTye0s6lkFASQ,1540
|
6
6
|
p123client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
p123client/tool/__init__.py,sha256=2k_tcc67O9QG4wzESIdnAwqNHybCGlrsnxo_uBqBhEI,16673
|
8
8
|
p123client/type.py,sha256=T17OzPQrnIG6w_Hzjc8TF_fFMKa-hQMSn1gff8pVcBc,56
|
9
|
-
p123client-0.0.6.
|
10
|
-
p123client-0.0.6.
|
11
|
-
p123client-0.0.6.
|
12
|
-
p123client-0.0.6.
|
9
|
+
p123client-0.0.6.4.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
10
|
+
p123client-0.0.6.4.dist-info/METADATA,sha256=7l04-PIItAf9zNy88qMzDiis2KeBX8HNucLCtvsO3ik,8855
|
11
|
+
p123client-0.0.6.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
12
|
+
p123client-0.0.6.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|