mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-14 18:54:27 +00:00
Fix emoji caching
This commit is contained in:
parent
6d0d1d6480
commit
6592841558
2 changed files with 10 additions and 7 deletions
|
@ -196,17 +196,20 @@ class MediaCache(object):
|
|||
def cache_emoji(self, url: str, iri: str) -> None:
|
||||
if self.is_emoji_cached(url):
|
||||
return
|
||||
src, content_type = _load(url, self.user_agent)
|
||||
with BytesIO() as buf:
|
||||
with GzipFile(mode="wb", fileobj=buf) as g:
|
||||
copyfileobj(src, g)
|
||||
i = load(url, self.user_agent)
|
||||
for size in [25]:
|
||||
t1 = i.copy()
|
||||
t1.thumbnail((size, size))
|
||||
with BytesIO() as buf:
|
||||
with GzipFile(mode="wb", fileobj=buf) as f1:
|
||||
t1.save(f1, format=i.format)
|
||||
buf.seek(0)
|
||||
self.fs.put(
|
||||
buf,
|
||||
url=url,
|
||||
size=size,
|
||||
remote_id=iri,
|
||||
size=None,
|
||||
content_type=content_type or mimetypes.guess_type(url)[0],
|
||||
content_type=i.get_format_mimetype(),
|
||||
kind=Kind.EMOJI.value,
|
||||
)
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ def replace_custom_emojis(content, note):
|
|||
for tag in note.get("tag", []):
|
||||
if tag.get("type") == "Emoji":
|
||||
# try:
|
||||
idx[tag["name"]] = _get_file_url(tag["icon"]["url"], None, Kind.EMOJI)
|
||||
idx[tag["name"]] = _get_file_url(tag["icon"]["url"], 25, Kind.EMOJI)
|
||||
|
||||
for emoji_name, emoji_url in idx.items():
|
||||
content = content.replace(
|
||||
|
|
Loading…
Reference in a new issue