export: set the proper file time for each emote

This commit is contained in:
Io Mintz 2019-10-15 22:54:31 +00:00
parent e32890fb60
commit 89ec168e87
1 changed files with 8 additions and 1 deletions

View File

@ -214,8 +214,15 @@ class Emotes(commands.Cog):
async with context.typing():
with zipfile.ZipFile(out, 'w', compression=zipfile.ZIP_STORED) as zip:
async def store(emote):
# place some level of trust on discord's CDN to actually give us images
data = await self.fetch_safe(str(emote.url), validate_headers=False)
zip.writestr(f'{emote.name}.{"gif" if emote.animated else "png"}', data)
if type(data) is str:
await context.send(f'{emote}: {data}')
return
zinfo = zipfile.ZipInfo(
f'{emote.name}.{"gif" if emote.animated else "png"}',
date_time=emote.created_at.timetuple()[:6])
zip.writestr(zinfo, data)
await utils.gather_or_cancel(*(store(emote) for emote in emotes))
out.seek(0)