From e9f6aef6f19fc97fdaf8c48554102b070678d1e4 Mon Sep 17 00:00:00 2001 From: Mynacol Date: Tue, 30 Sep 2025 19:46:00 +0000 Subject: [PATCH] [GolemBridge] Fix YouTube embeds Apparently, the script element containing the YouTube URI is not the 15th one anymore. Replacing it with a foreach loop to find it irrespective of where this script element is. There is a chance to find a different YouTube embed. But the original approach didn't support multiple YouTube embeds anyways. And fixing that is hard. --- bridges/GolemBridge.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bridges/GolemBridge.php b/bridges/GolemBridge.php index d127a1e6..51edcad2 100644 --- a/bridges/GolemBridge.php +++ b/bridges/GolemBridge.php @@ -117,14 +117,16 @@ class GolemBridge extends FeedExpander //built youtube iframes foreach ($article->find('.go-embed-container') as &$embedcontent) { - $ytscript = $page->find('script', 14); - if (preg_match('/(www.youtube.com.*?)\"/', $ytscript->innertext, $link)) { - $link = 'https://' . str_replace('\\', '', $link[1]); - $embedcontent->innertext .= <<'; - EOT; + foreach ($page->find('script') as $ytscript) { + if (preg_match('/(www.youtube.com.*?)\"/', $ytscript->innertext, $link)) { + $link = 'https://' . str_replace('\\', '', $link[1]); + $embedcontent->innertext .= <<'; + EOT; + break; + } } }