Store images without file extension
This commit is contained in:
parent
e14c126b2b
commit
c1af0c14e7
1 changed files with 1 additions and 6 deletions
|
@ -4,7 +4,6 @@ import sys
|
|||
import os
|
||||
import re
|
||||
import json
|
||||
import mimetypes
|
||||
import urllib.request
|
||||
|
||||
|
||||
|
@ -46,12 +45,8 @@ def get_emoji_image(name, emoji_id):
|
|||
print(f"Downloading {name}", file=sys.stderr, flush=True)
|
||||
with mm_api_get(f"/v4/emoji/{emoji_id}/image") as upstream_response:
|
||||
headers = {k.lower(): v for (k, v) in upstream_response.headers.items()}
|
||||
mime = headers.get("content-type")
|
||||
if not mime.startswith("image/"):
|
||||
raise Exception(f"Got response with MIME type {mime}, not an image")
|
||||
extension = mimetypes.guess_extension(mime)
|
||||
|
||||
filepath = f"{destination_dir}/{name}{extension}"
|
||||
filepath = f"{destination_dir}/{name}"
|
||||
with open(filepath, "wb") as fh:
|
||||
chunk = upstream_response.read1()
|
||||
while chunk != b"":
|
||||
|
|
Loading…
Reference in a new issue