diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php index b10db9e..b4c3f6c 100644 --- a/bridges/YoutubeBridge.php +++ b/bridges/YoutubeBridge.php @@ -56,9 +56,19 @@ class YoutubeBridge extends BridgeAbstract { return; } - $author = $html->innertext; - $author = substr($author, strpos($author, '"author=') + 8); - $author = substr($author, 0, strpos($author, '\u0026')); + foreach($html->find('script') as $script){ + $data = trim($script->innertext); + + if(strpos($data, '{') !== 0) + continue; // Wrong script + + $json = json_decode($data); + + if(!isset($json->itemListElement)) + continue; // Wrong script + + $author = $json->itemListElement[0]->item->name; + } if(!is_null($html->find('div#watch-description-text', 0))) $desc = $html->find('div#watch-description-text', 0)->innertext;