commit 34972c72620c051db7fe3bcef5b78b632cbdfc47 Author: MMaker Date: Fri Jan 31 12:37:28 2025 -0500 first! diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd601c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +venv +.venv +__pycache__ \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..2468a2a --- /dev/null +++ b/app.py @@ -0,0 +1,38 @@ +from flask import Flask, Response +import requests +from bs4 import BeautifulSoup + +app = Flask(__name__) +s = requests.Session() +s.headers.update({ + "User-Agent": "Twitterbot/1.0" +}) + +@app.route("/watch/") +def proxy(video_id): + real_url = f"https://www.nicovideo.jp/watch/{video_id}" + + try: + r = s.get(real_url, timeout=10) + except requests.RequestException as e: + return Response(f"Error fetching the page: {e}", status=500) + + soup = BeautifulSoup(r.text, "html.parser") + og_tags = soup.find_all("meta", property=lambda x: x) + og_tags_str = "\n".join(str(tag) for tag in og_tags) + html_response = f""" + + + + + {og_tags_str} + + + + + """ + + return Response(html_response, mimetype="text/html") + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000, debug=True)