From e942d734742ffca03bb2dadda2dfa0c513a0ca31 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Tue, 25 May 2021 13:23:05 +0200 Subject: [PATCH] image size regex --- backend/stream.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/backend/stream.py b/backend/stream.py index 54069fc..9a8d8cd 100755 --- a/backend/stream.py +++ b/backend/stream.py @@ -370,13 +370,9 @@ class MainHandler(tornado.web.RequestHandler): image = meta.get("og:image") if isinstance(image, str): if handler.provider == "youtube": - full_image = None + full_image = re.sub(r'\/[a-zA-Z0-9]+\.([a-zA-Z0-9]+)$', r'/maxresdefault.\1', image) image_type = None - if image.endswith("hqdefault.jpg"): - full_image = image.removesuffix("hqdefault.jpg") + "maxresdefault.jpg" - elif image.endswith("hqdefault.webp"): - full_image = image.removesuffix("hqdefault.webp") + "maxresdefault.webp" - if isinstance(full_image, str): + if full_image != image: image_type = await handler.proxy.content_type(full_image) if isinstance(image_type, str) and image_type.startswith("image"): image = full_image