From 0c2099a8529faad54d848dd73cfc6bd839abb5ba Mon Sep 17 00:00:00 2001 From: Tone <66808319+Tone866@users.noreply.github.com> Date: Thu, 28 Mar 2024 19:41:56 +0100 Subject: [PATCH] [GolemBridge] fixed embedded youtube videos (#4033) * [GolemBridge] fixed embedded youtube videos embedded youtube-videos can be played directly from feed now * Update GolemBridge.php * Update GolemBridge.php * Update GolemBridge.php * Update GolemBridge.php --- bridges/GolemBridge.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bridges/GolemBridge.php b/bridges/GolemBridge.php index 599d713a..216e913f 100644 --- a/bridges/GolemBridge.php +++ b/bridges/GolemBridge.php @@ -106,10 +106,23 @@ class GolemBridge extends FeedExpander $article = $page->find('article', 0); + //built youtube iframes + foreach ($article->find('.embedcontent') as &$embedcontent) { + $ytscript = $embedcontent->find('script', 0); + if (preg_match('/www.youtube.com.*?\"/', $ytscript->innertext, $link)) { + $link = 'https://' . str_replace('\\', '', $link[0]); + $embedcontent->innertext .= <<'; + EOT; + } + } + // delete known bad elements foreach ( $article->find('div[id*="adtile"], #job-market, #seminars, iframe, - div.gbox_affiliate, div.toc, .embedcontent, script') as $bad + div.gbox_affiliate, div.toc') as $bad ) { $bad->remove(); } @@ -129,7 +142,7 @@ class GolemBridge extends FeedExpander $img->src = $img->getAttribute('data-src-full'); } - foreach ($content->find('p, h1, h2, h3, img[src*="."]') as $element) { + foreach ($content->find('p, h1, h2, h3, img[src*="."], iframe') as $element) { $item .= $element; }