-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
utils.py
25 lines (22 loc) · 875 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from datetime import datetime
from avilla.standard.core.file.metadata import DownloadInfo, FileData
from avilla.core.selector import Selector
def filedata_parse(raw: dict):
return FileData(
raw["id"],
Selector().land("qq").group(str(raw["contact"]["id"])),
raw["name"],
filedata_parse(raw["parent"]) if raw["parent"] else None,
raw["isFile"],
raw["isDirectory"],
datetime.fromtimestamp(raw["uploadTime"]) if raw["uploadTime"] else None,
datetime.fromtimestamp(raw["lastModifyTime"]) if raw["lastModifyTime"] else None,
DownloadInfo(
raw["downloadInfo"].get("downloadTimes", raw["downloadTimes"]),
raw["downloadInfo"]["url"],
raw["downloadInfo"]["sha1"],
raw["downloadInfo"]["md5"],
)
if raw["downloadInfo"]
else None,
)