From 2b74116f12b2944b74588db32b635c1603b5bb2a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 17 Dec 2021 10:07:49 +0000 Subject: [PATCH] Tidying --- session.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/session.py b/session.py index ec9b0949c..b4f7ab3f5 100644 --- a/session.py +++ b/session.py @@ -493,12 +493,17 @@ def downloadImageAnyMimeType(session, url: str, timeoutSec: int, debug: bool): if not contentType: return None, None - if 'image/x-icon' in contentType: - mimeType = 'image/x-icon' - elif 'image/webp' in contentType: - mimeType = 'image/webp' - elif 'image/jpeg' in contentType: - mimeType = 'image/jpeg' - elif 'image/gif' in contentType: - mimeType = 'image/gif' + imageFormats = { + 'ico': 'x-icon', + 'png': 'png', + 'jpg': 'jpeg', + 'jpeg': 'jpeg', + 'gif': 'gif', + 'svg': 'svg+xml', + 'webp': 'webp', + 'avif': 'avif' + } + for imFormat, mType in imageFormats.items(): + if 'image/' + mType in contentType: + mimeType = 'image/' + mType return result.content, mimeType