1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-10-14 16:24:34 +02:00

[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.
This commit is contained in:
Mynacol
2025-09-30 19:46:00 +00:00
parent 447cf071cb
commit e9f6aef6f1

View File

@@ -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
<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;
foreach ($page->find('script') as $ytscript) {
if (preg_match('/(www.youtube.com.*?)\"/', $ytscript->innertext, $link)) {
$link = 'https://' . str_replace('\\', '', $link[1]);
$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;
break;
}
}
}