From c529fc87fd6ed7b39bf057bce44ef30d1bc17f1b Mon Sep 17 00:00:00 2001
From: retoor <retoor@molodetz.nl>
Date: Wed, 9 Apr 2025 11:07:09 +0200
Subject: [PATCH] New video embedding

---
 src/snek/system/template.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/snek/system/template.py b/src/snek/system/template.py
index 1a1175e..d04f56e 100644
--- a/src/snek/system/template.py
+++ b/src/snek/system/template.py
@@ -91,16 +91,15 @@ def embed_youtube(text):
     for element in soup.find_all("a"):
         if (
             element.attrs["href"].startswith("https://www.you")
-            and ("v=" in element.attrs["href"] or "si=" in element.attrs["href"])
         ):
-            video_name = None 
-            if "v=" in element.attrs["href"]:
-                video_name = element.attrs["href"].split("?v=")[1].split("&")[0]
-            if "si=" in element.attrs["href"]:
-                video_name = "?v=" + element.attrs["href"].split("/")[-1]
-            if "t=" in element.attrs["href"]:
-                video_name += "&t=" + element.attrs["href"].split("&t=")[1].split("&")[0]
-            embed_template = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_name}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
+            video_name = element.attrs["href"].split("/")[-1]
+            #if "v=" in element.attrs["href"]:
+            #    video_name = element.attrs["href"].split("?v=")[1].split("&")[0]
+            #if "si=" in element.attrs["href"]:
+            #    video_name = "?v=" + element.attrs["href"].split("/")[-1]
+            #if "t=" in element.attrs["href"]:
+            #    video_name += "&t=" + element.attrs["href"].split("&t=")[1].split("&")[0]
+            embed_template = f'<iframe width="560" height="315" style="display:block;" src="https://www.youtube.com/embed/{video_name}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
             element.replace_with(BeautifulSoup(embed_template, "html.parser"))
     return str(soup)