Attempt to embed as iframe

This commit is contained in:
MMaker 2025-01-31 18:46:32 -05:00
parent fb3ee42ead
commit f83d853fec
Signed by: mmaker
GPG Key ID: CCE79B8FEDA40FB2

7
app.py
View File

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