redirect to repo if no video is requested
Marco Andronaco andronacomarco@gmail.com
Tue, 22 Aug 2023 09:07:44 +0200
3 files changed,
5 insertions(+),
5 deletions(-)
M
README.md
→
README.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.py
→
fxyoutube/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.py
→
fxyoutube/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)