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:
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:
except Exception:
return False