p115client 0.0.5.12.3__py3-none-any.whl → 0.0.5.13.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/tool/attr.py CHANGED
@@ -13,11 +13,13 @@ from p115client import check_response, normalize_attr_web, P115Client
13
13
  from p115client.const import CLASS_TO_TYPE, SUFFIX_TO_TYPE
14
14
  from posixpatht import splitext
15
15
 
16
+ from p115pickcode import to_id
17
+
16
18
 
17
19
  @overload
18
20
  def get_attr(
19
21
  client: str | P115Client,
20
- id: int,
22
+ id: int | str,
21
23
  skim: bool = False,
22
24
  *,
23
25
  async_: Literal[False] = False,
@@ -27,7 +29,7 @@ def get_attr(
27
29
  @overload
28
30
  def get_attr(
29
31
  client: str | P115Client,
30
- id: int,
32
+ id: int | str,
31
33
  skim: bool = False,
32
34
  *,
33
35
  async_: Literal[True],
@@ -36,7 +38,7 @@ def get_attr(
36
38
  ...
37
39
  def get_attr(
38
40
  client: str | P115Client,
39
- id: int,
41
+ id: int | str,
40
42
  skim: bool = False,
41
43
  *,
42
44
  async_: Literal[False, True] = False,
@@ -44,8 +46,11 @@ def get_attr(
44
46
  ) -> dict | Coroutine[Any, Any, dict]:
45
47
  """获取文件或目录的信息
46
48
 
49
+ .. note::
50
+ 不要传入根目录,即不能是 0 或 ""
51
+
47
52
  :param client: 115 客户端或 cookies
48
- :param id: 文件或目录的 id
53
+ :param id: 文件或目录的 id 或 pickcode
49
54
  :param skim: 是否获取简要信息(可避免风控)
50
55
  :param async_: 是否异步
51
56
  :param request_kwargs: 其它请求参数
@@ -54,6 +59,7 @@ def get_attr(
54
59
  """
55
60
  if isinstance(client, str):
56
61
  client = P115Client(client, check_for_relogin=True)
62
+ id = to_id(id)
57
63
  def gen_step():
58
64
  from dictattr import AttrDict
59
65
  if skim:
@@ -92,7 +98,7 @@ def type_of_attr(attr: Mapping, /) -> int:
92
98
  - 7: 书籍
93
99
  - 99: 其它文件
94
100
  """
95
- if attr.get("is_dir") or attr.get("is_directory"):
101
+ if attr.get("is_dir"):
96
102
  return 0
97
103
  type: None | int
98
104
  if type := CLASS_TO_TYPE.get(attr.get("class", "")):