From e38417dd9a4542bc6876b32f4e4f7ceb2dab943a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 22 Aug 2021 21:51:19 +0200 Subject: [PATCH] gfgf --- files/helpers/sanitize.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index a3558b8a7..6e9fb73fd 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -172,14 +172,27 @@ def sanitize(sanitized): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f':{i.group(1)}:', f'') - sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/embed/").replace("https://music.youtube.com/watch?v=", "https://youtube.com/embed/").replace("/watch?v=", "/embed/").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/embed/") + sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=") - for i in re.finditer('https://youtube.com/watch?v=' in sanitized: + sanitized = sanitized.replace("watch?v=", "embed/") + url = re.search('(https://youtube.com/embed/.*?)"', sanitized).group(1) + replacing = f'

{url}

' + htmlsource = f'
' + sanitized = sanitized.replace(replacing, htmlsource) + + for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)', sanitized): + url = i.group(1) + replacing = f'{url}' + htmlsource = f'
' + sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/")) + + for i in re.finditer('{url}' htmlsource = f'
' sanitized = sanitized.replace(replacing, htmlsource) - + for i in re.finditer('{url}'