Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/user/dpng.py
2022-04-08 15:17:39 +08:00

32 lines
984 B
Python

import os
from os.path import abspath
import aiohttp
from modules.wiki.wikilib import WikiLib
async def dpng(link, ss):
check = await WikiLib(link).check_wiki_available()
if check:
imgurl = check.value.logo_url
if imgurl is not None:
d = abspath('./assets/Favicon/' + ss + '/')
if not os.path.exists(d):
os.makedirs(d)
path = d + '/Wiki.png'
try:
if not os.path.exists(d):
os.mkdir(d)
if not os.path.exists(path):
async with aiohttp.ClientSession() as session:
async with session.get(imgurl) as resp:
with open(path, 'wb+') as jpg:
jpg.write(await resp.read())
return True
else:
return True
except Exception:
return False
return False