From 7c1a99dde88895bf61db36f7e0ef5e2a9e0d9d55 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Thu, 27 May 2021 20:55:08 +0200 Subject: [PATCH] simplify image fetcher --- backend/stream.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/backend/stream.py b/backend/stream.py index 7217350..09b1813 100755 --- a/backend/stream.py +++ b/backend/stream.py @@ -226,18 +226,10 @@ class UpstreamHandler(): if self.provider == "youtube": full_image = re.sub(r'\/[a-zA-Z0-9]+\.([a-zA-Z0-9]+)$', r'/maxresdefault.\1', image) standard_image = re.sub(r'\/[a-zA-Z0-9]+\.([a-zA-Z0-9]+)$', r'/sddefault.\1', image) - image_status_standard_future = None - image_status_full_future = None - if full_image != image: - image_status_full_future = session.head(full_image) - if standard_image != image: - image_status_standard_future = session.head(standard_image) - image_status_full = None - image_status_standard = None - if image_status_standard_future is not None: - image_status_standard = await image_status_standard_future - if image_status_full_future is not None: - image_status_full = await image_status_full_future + image_status_full_future = session.head(full_image) + image_status_standard_future = session.head(standard_image) + image_status_full = await image_status_full_future + image_status_standard = await image_status_standard_future if hasattr(image_status_full, "status") and (image_status_full.status < 400): data["og:image"] = full_image elif hasattr(image_status_standard, "status") and (image_status_standard.status < 400):