diff --git a/app.py b/app.py index e486fd9..f824be3 100644 --- a/app.py +++ b/app.py @@ -231,6 +231,8 @@ def proxy(video_id): cdn_video_url = get_cdn_url(video_id) og_tags = soup.find_all("meta", property=lambda x: x) # type: ignore + og_video_width = None + og_video_height = None for tag in og_tags: # Fix thumbnail if tag.get("property") == "og:image" and thumbnail_url: @@ -238,19 +240,31 @@ def proxy(video_id): # Fix video URL if tag.get("property") == "og:video:url" or tag.get("property") == "og:video:secure_url": tag["content"] = cdn_video_url + # Set vars + if tag.get("property") == "og:video:width": + og_video_width = tag.get("content") + if tag.get("property") == "og:video:height": + og_video_height = tag.get("content") og_tags_str = "\n".join(str(tag) for tag in og_tags) - html_response = f""" - - -
- - {og_tags_str} - - - - - """ + og_tags_str += '\n' + og_tags_str += '\n' + og_tags_str += f'\n' + if og_video_width: + og_tags_str += f'\n' + if og_video_height: + og_tags_str += f'\n' + html_response = f""" + + +{og_tags_str} +""" if cache: logging.info(f"Caching response for video ID: {video_id}")