1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

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

View file

@ -214,8 +214,15 @@ class Emotes(commands.Cog):
async with context.typing(): async with context.typing():
with zipfile.ZipFile(out, 'w', compression=zipfile.ZIP_STORED) as zip: with zipfile.ZipFile(out, 'w', compression=zipfile.ZIP_STORED) as zip:
async def store(emote): 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) 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)) await utils.gather_or_cancel(*(store(emote) for emote in emotes))
out.seek(0) out.seek(0)