Skip to content

Commit 7f96f03

Browse files
committed
Support import/export KID cookie.
1 parent 49dfa27 commit 7f96f03

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ from py115 import Cloud
1313
cloud = Cloud(credential={
1414
'UID': 'UID-value-in-cookie',
1515
'CID': 'CID-value-in-cookie',
16+
'KID': 'KID-value-in-cookie',
1617
'SEID': 'SEID-value-in-cookie',
1718
})
1819

src/py115/cloud.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,13 @@ def export_credentail(self) -> Credential | None:
325325
"""Export current credentail from cloud instance.
326326
327327
Return:
328-
py115.types.Credential: Credential object, or None when credential is invalid.
328+
Credential: Credential object, or None when credential is invalid.
329329
"""
330330
cookies = self._lac.export_cookies()
331331
cred = Credential(
332332
uid=cookies.get('UID', None),
333333
cid=cookies.get('CID', None),
334+
kid=cookies.get('KID', None),
334335
seid=cookies.get('SEID', None)
335336
)
336337
return cred if cred else None
@@ -423,6 +424,6 @@ def _convert_to_cookies(credential: Any) -> Dict[str, str] | None:
423424
cookies = {}
424425
for key, value in raw.items():
425426
key = key.upper()
426-
if key in ('UID', 'CID', 'SEID'):
427+
if key in ('UID', 'CID', 'KID', 'SEID'):
427428
cookies[key] = str(value)
428429
return cookies

src/py115/types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class Credential:
6161
"CID" cookie value.
6262
"""
6363

64+
kid: str | None
65+
"""
66+
"KID" cookie value.
67+
"""
68+
6469
seid: str | None
6570
"""
6671
"SEID" cookie value.
@@ -75,7 +80,8 @@ def to_dict(self) -> Dict[str, str]:
7580
return {
7681
'UID': self.uid,
7782
'CID': self.cid,
78-
'SEID': self.seid,
83+
'KID': self.kid,
84+
'SEID': self.seid
7985
}
8086

8187
def __bool__(self) -> bool:

0 commit comments

Comments
 (0)