diff --git a/files/routes/posts.py b/files/routes/posts.py index a4dafb655..ac138656f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -733,15 +733,14 @@ def submit_post(v): elif "twitter.com" == domain: try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"] except: embed = None - elif "youtu" in domain: - yt_id = re.match(re.compile("^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|shorts\/|\&v=)([^#\&\?]*).*"), url).group(2) + elif url.startswith('https://youtube.com/watch?v='): + yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0] params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] if isinstance(t, str): t = t.replace('s','') embed = f'' - elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url: id = url.split("/post/")[1] if "/" in id: id = id.split("/")[0]