image size regex

This commit is contained in:
Roy Olav Purser 2021-05-25 13:23:05 +02:00
parent 51530c2a6b
commit e942d73474
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -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