def parse_category(response: aiohttp.Response):
'''
response can be parsed to a json-object.
The field `Count` stands for how many emojis this category have.
The field `title` is the name of this category.
'''
js = await response.json()
if not js.get("Count", 0):
return
category = js.get("title", "").strip() # name of folder no blank space
if not category:
return
confirmDir(category)
# emojis contained by `picList`
for pic in js.get("picList", []):
src = pic.get("link", "") # emoji's download link
eid = pic.get("eid", "") # emoji's id
if not src:
continue
# name for saving
name = str(eid) + splitext(src)[1] if eid else basename(src)
dst = join(os.curdir, category, name)
await ss.download(src, dst)
评论列表
文章目录