[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
This commit is contained in:
Tone 2024-03-28 19:41:56 +01:00 committed by GitHub
parent fee5e269d0
commit 0c2099a852
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
<iframe width="560" height="315" src=$link 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>';
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;
}