From 9bfc5687e8b4509babc45269c3bce39562630617 Mon Sep 17 00:00:00 2001 From: Mynacol Date: Fri, 24 Oct 2025 12:25:00 +0000 Subject: [PATCH] [GolemBridge] Fix multiple YouTube embeds The following test article revealed that the previous code always takes the first youtube link on all YouTube embed spaces: https://www.golem.de/news/free-to-play-kostenlos-skaten-ballern-und-klicken-2510-201000.html This command changes it to opportunistically select the i-th youtube embed link for the i-th placeholder. This might fail and produce wrong orderings, but should be better than the previous code. The above test article is at least completely correct. --- bridges/GolemBridge.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bridges/GolemBridge.php b/bridges/GolemBridge.php index 51edcad2..85130764 100644 --- a/bridges/GolemBridge.php +++ b/bridges/GolemBridge.php @@ -116,11 +116,12 @@ class GolemBridge extends FeedExpander $article = $page->find('article', 0); //built youtube iframes - foreach ($article->find('.go-embed-container') as &$embedcontent) { + $placeholders = $article->find('.go-embed-container'); + foreach (range(0, count($placeholders) - 1) as $i) { foreach ($page->find('script') as $ytscript) { - if (preg_match('/(www.youtube.com.*?)\"/', $ytscript->innertext, $link)) { - $link = 'https://' . str_replace('\\', '', $link[1]); - $embedcontent->innertext .= <<innertext, $link)) { + $link = 'https://' . str_replace('\\', '', $link[1][$i]); + $placeholders[$i]->innertext .= <<';