[YouTubeCommunityTabBridge] Improve JSON extraction (#4140)

Small change that should make the extraction of JSON from HTML work more
reliably
This commit is contained in:
Thomas 2024-06-24 22:32:03 +02:00 committed by GitHub
parent 2a84350cb2
commit adad9d6405
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,7 +32,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
private $itemTitle = '';
private $urlRegex = '/youtube\.com\/(channel|user|c)\/([\w]+)\/community/';
private $jsonRegex = '/var ytInitialData = (.*);<\/script>/';
private $jsonRegex = '/var ytInitialData = ([^<]*);<\/script>/';
public function detectParameters($url)
{
@ -70,7 +70,7 @@ class YouTubeCommunityTabBridge extends BridgeAbstract
$html = getSimpleHTMLDOM($this->feedUrl);
}
$json = $this->extractJson($html->find('body', 0)->innertext);
$json = $this->extractJson($html->find('html', 0)->innertext);
$this->feedName = $json->header->c4TabbedHeaderRenderer->title;