fix(rumble): not all videos have a datetime (#3852)

This commit is contained in:
Dag 2023-12-21 09:18:21 +01:00 committed by GitHub
parent a81acbe464
commit 4c5cf89725
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,15 +40,18 @@ class RumbleBridge extends BridgeAbstract
$dom = getSimpleHTMLDOM($url); $dom = getSimpleHTMLDOM($url);
foreach ($dom->find('ol.thumbnail__grid div.thumbnail__grid--item') as $video) { foreach ($dom->find('ol.thumbnail__grid div.thumbnail__grid--item') as $video) {
$datetime = $video->find('time', 0)->getAttribute('datetime'); $item = [
$this->items[] = [
'title' => $video->find('h3', 0)->plaintext, 'title' => $video->find('h3', 0)->plaintext,
'uri' => self::URI . $video->find('a', 0)->href, 'uri' => self::URI . $video->find('a', 0)->href,
'timestamp' => (new \DateTimeImmutable($datetime))->getTimestamp(),
'author' => $account . '@rumble.com', 'author' => $account . '@rumble.com',
'content' => defaultLinkTo($video, self::URI)->innertext, 'content' => defaultLinkTo($video, self::URI)->innertext,
]; ];
$time = $video->find('time', 0);
if ($time) {
$publishedAt = new \DateTimeImmutable($time->getAttribute('datetime'));
$item['timestamp'] = $publishedAt->getTimestamp();
}
$this->items[] = $item;
} }
} }