[YoutubeBridge] Fix empty result in search feed (#4098)

This commit is contained in:
Eugene Molotov 2024-05-06 02:30:23 +05:00 committed by GitHub
parent d15960f955
commit f480209825
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -193,14 +193,7 @@ class YoutubeBridge extends BridgeAbstract
$html = $this->fetch($url_listing); $html = $this->fetch($url_listing);
$jsonData = $this->extractJsonFromHtml($html); $jsonData = $this->extractJsonFromHtml($html);
$jsonData = $jsonData->contents->twoColumnSearchResultsRenderer->primaryContents; $jsonData = $jsonData->contents->twoColumnSearchResultsRenderer->primaryContents;
$jsonData = $jsonData->sectionListRenderer->contents; $jsonData = $jsonData->sectionListRenderer->contents[0]->itemSectionRenderer->contents;
foreach ($jsonData as $data) {
// Search result includes some ads, have to filter them
if (isset($data->itemSectionRenderer->contents[0]->videoRenderer)) {
$jsonData = $data->itemSectionRenderer->contents;
break;
}
}
$this->fetchItemsFromFromJsonData($jsonData); $this->fetchItemsFromFromJsonData($jsonData);
$this->feeduri = $url_listing; $this->feeduri = $url_listing;
$this->feedName = 'Search: ' . $search; $this->feedName = 'Search: ' . $search;