all repos — FixYouTube-legacy @ b7c5b69f69a43efd50217fc0501b072d8c11b36f

A better way to embed YouTube videos everywhere (inspired by FixTweet).

redirect to repo if no video is requested
Marco Andronaco andronacomarco@gmail.com
Tue, 22 Aug 2023 09:07:44 +0200
commit

b7c5b69f69a43efd50217fc0501b072d8c11b36f

parent

22eca08269087fac9db84faaf39ddc1d32f09e4e

3 files changed, 5 insertions(+), 5 deletions(-)

jump to
M README.mdREADME.md

@@ -1,7 +1,7 @@

# FixYouTube Embed YouTube videos on Telegram! -### Docker +## Docker ``` docker-compose up -d ```

@@ -12,8 +12,7 @@ poetry install

poetry run flask --app fxyoutube run --port 1111 --debug ``` - -## Production +### Production ``` poetry install --with prod poetry run waitress-serve --port 1111 fxyoutube:app
M fxyoutube/constants.pyfxyoutube/constants.py

@@ -4,5 +4,6 @@ DB_URL = "cache.db"

UA_REGEX = r"bot|facebook|embed|got|firefox\/92|firefox\/38|curl|wget|go-http|yahoo|generator|whatsapp|preview|link|proxy|vkshare|images|analyzer|index|crawl|spider|python|cfnetwork|node" BASE_URL = "https://www.youtube.com/watch?v=" +REPO_URL = "https://github.com/BiRabittoh/fxyoutube" TS_FORMAT = "%Y-%m-%d %H:%M:%S" MAX_SIZE_BYTES = MAX_SIZE_MB * 1_000_000
M fxyoutube/views.pyfxyoutube/views.py

@@ -8,10 +8,10 @@ import re

def main_handler(request, video_id): if video_id == "": - return abort(400) + return redirect(c.REPO_URL) + user_agent = request.headers.get("User-Agent", "") result = re.findall(c.UA_REGEX, user_agent, flags=re.I) - if len(result) == 0: return redirect(c.BASE_URL + video_id)