show number of emojis and the zip size

pull/134/head
Aevann 2023-02-25 21:18:40 +02:00
parent e927148bf5
commit 00c70a23fb
3 changed files with 13 additions and 3 deletions

View File

@ -1,9 +1,10 @@
import datetime
import time
import os
from sys import stdout
from shutil import make_archive
from hashlib import md5
import click
import requests
@ -119,3 +120,9 @@ def _generate_emojis_zip():
m.update(data)
cache.set('emojis_hash', m.hexdigest())
count = str(len(os.listdir('files/assets/images/emojis')))
cache.set('emojis_count', count)
size = str(int(os.stat('files/assets/emojis.zip').st_size/1024/1024)) + ' MB'
cache.set('emojis_size', size)

View File

@ -205,7 +205,10 @@ def static_megathread_index(v:User):
abort(404)
emojis_hash = cache.get('emojis_hash') or ''
return render_template("megathread_index.html", v=v, emojis_hash=emojis_hash)
emojis_count = cache.get('emojis_count') or ''
emojis_size = cache.get('emojis_size') or ''
return render_template("megathread_index.html", v=v, emojis_hash=emojis_hash, emojis_count=emojis_count, emojis_size=emojis_size)
@app.get("/api")
@limiter.limit(DEFAULT_RATELIMIT, key_func=get_ID)

View File

@ -9,7 +9,7 @@
{%- do MEGATHREAD_INDEX.extend([
(
'Download All Emojis',
'Download a zip file containing all emojis.',
'Download a zip file containing all emojis.<br>' ~ emojis_count ~ ' emojis - ' ~ emojis_size,
'fa-down', '#38a169',
'/assets/emojis.zip?v=' + emojis_hash,
),