From f83d853fecb6fd1e155c2d3fb7a3a7bb3a1842eb Mon Sep 17 00:00:00 2001 From: MMaker Date: Fri, 31 Jan 2025 18:46:32 -0500 Subject: [PATCH] Attempt to embed as iframe --- app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 270a7c0..25141f5 100644 --- a/app.py +++ b/app.py @@ -23,7 +23,7 @@ except FileNotFoundError: s = requests.Session() s.headers.update({ - "User-Agent": "Twitterbot/1.0" + "User-Agent": "Googlebot/2.1" }) s.cookies = cookie_jar # type: ignore @@ -64,8 +64,13 @@ def proxy(video_id): og_tags = soup.find_all("meta", property=lambda x: x) # type: ignore for tag in og_tags: + # Fix thumbnail if tag.get("property") == "og:image" and thumbnail_url: tag["content"] = thumbnail_url + break + # Fix embed (Niconico doesn't return MP4s) + if tag.get("property") == "og:video:type": + tag["content"] = "text/html" og_tags_str = "\n".join(str(tag) for tag in og_tags) html_response = f"""