Skip to content

Commit

Permalink
[GolemBridge] fixed embedded youtube videos (#4033)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
Tone866 committed Mar 28, 2024
1 parent fee5e26 commit 0c2099a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bridges/GolemBridge.php
Expand Up @@ -106,10 +106,23 @@ private function extractContent($page)

$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();
}
Expand All @@ -129,7 +142,7 @@ private function extractContent($page)
$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;
}

Expand Down

0 comments on commit 0c2099a

Please sign in to comment.