From 44e90d9b7bc1abaede56a7562feea06a476d7309 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 8 Dec 2021 04:03:12 +0200 Subject: [PATCH] sfdsfd --- files/helpers/sanitize.py | 2 +- files/routes/posts.py | 2 +- files/templates/submission.html | 31 +++++++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 0f8c832c4..fe743774b 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -212,7 +212,6 @@ def sanitize(sanitized, noimages=False): 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=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube") - if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=") for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))', sanitized): @@ -220,6 +219,7 @@ def sanitize(sanitized, noimages=False): yt_id = i.group(2).split('&')[0].split('%')[0] replacing = f'{url}' + print(url) params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') diff --git a/files/routes/posts.py b/files/routes/posts.py index c27e6c90c..99ebea693 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -699,7 +699,7 @@ def submit_post(v): for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: url = url.replace(rd, "https://old.reddit.com/") - url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery").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=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube") + url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery").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=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube") if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/") diff --git a/files/templates/submission.html b/files/templates/submission.html index fba36ea40..cd9ad5c7e 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -424,6 +424,23 @@ {% endif %} {% endif %} + + + {% if p.embed_url %} + {% if p.domain == "twitter.com" %} + {{p.embed_url | safe}} + {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %} + + {% else %} + + {% endif %} + + {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith(' {% if p.is_image %}
@@ -462,20 +479,6 @@
- {% if p.embed_url %} - {% if p.domain == "twitter.com" %} - {{p.embed_url | safe}} - {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %} - - {% else %} - - {% endif %} - - {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith('