2022-11-17 20:06:35 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RumbleBridge extends BridgeAbstract
|
|
|
|
{
|
2024-07-29 18:53:14 +03:00
|
|
|
const NAME = 'Rumble.com Bridge';
|
|
|
|
const URI = 'https://rumble.com/';
|
|
|
|
const DESCRIPTION = 'Fetches the latest channel/user videos and livestreams.';
|
|
|
|
const MAINTAINER = 'dvikan, NotsoanoNimus';
|
2022-11-17 20:06:35 +03:00
|
|
|
const CACHE_TIMEOUT = 60 * 60; // 1h
|
|
|
|
const PARAMETERS = [
|
|
|
|
[
|
|
|
|
'account' => [
|
|
|
|
'name' => 'Account',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
2024-07-29 18:53:14 +03:00
|
|
|
'title' => 'Name of the target account to create into a feed.',
|
2022-11-17 20:06:35 +03:00
|
|
|
'defaultValue' => 'bjornandreasbullhansen',
|
|
|
|
],
|
|
|
|
'type' => [
|
2024-07-29 18:53:14 +03:00
|
|
|
'name' => 'Account Type',
|
2022-11-17 20:06:35 +03:00
|
|
|
'type' => 'list',
|
2024-07-29 18:53:14 +03:00
|
|
|
'title' => 'The type of profile to create a feed from.',
|
2022-11-17 20:06:35 +03:00
|
|
|
'values' => [
|
2024-07-29 18:53:14 +03:00
|
|
|
'Channel (All)' => 'channel',
|
|
|
|
'Channel Videos' => 'channel-videos',
|
|
|
|
'Channel Livestreams' => 'channel-livestream',
|
|
|
|
'User (All)' => 'user',
|
|
|
|
],
|
2022-11-17 20:06:35 +03:00
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$account = $this->getInput('account');
|
|
|
|
$type = $this->getInput('type');
|
2024-07-29 18:53:14 +03:00
|
|
|
$url = self::getURI();
|
2022-11-17 20:06:35 +03:00
|
|
|
|
2024-07-29 18:53:14 +03:00
|
|
|
if (!preg_match('#^[\w\-_.@]+$#', $account) || strlen($account) > 64) {
|
|
|
|
throw new \Exception('Invalid target account.');
|
2022-11-17 20:06:35 +03:00
|
|
|
}
|
2024-07-29 18:53:14 +03:00
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case 'user':
|
|
|
|
$url .= "user/$account";
|
|
|
|
break;
|
|
|
|
case 'channel':
|
|
|
|
$url .= "c/$account";
|
|
|
|
break;
|
|
|
|
case 'channel-videos':
|
|
|
|
$url .= "c/$account/videos";
|
|
|
|
break;
|
|
|
|
case 'channel-livestream':
|
|
|
|
$url .= "c/$account/livestreams";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Shouldn't ever happen.
|
|
|
|
throw new \Exception('Invalid media type.');
|
2022-11-17 20:06:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$dom = getSimpleHTMLDOM($url);
|
2023-12-17 19:08:40 +03:00
|
|
|
foreach ($dom->find('ol.thumbnail__grid div.thumbnail__grid--item') as $video) {
|
2024-08-23 18:09:17 +03:00
|
|
|
$itemUrlString = self::URI . $video->find('a', 0)->href;
|
|
|
|
$itemUrl = Url::fromString($itemUrlString);
|
|
|
|
|
2023-12-21 11:18:21 +03:00
|
|
|
$item = [
|
2022-11-17 20:06:35 +03:00
|
|
|
'title' => $video->find('h3', 0)->plaintext,
|
2024-08-23 18:09:17 +03:00
|
|
|
|
|
|
|
// Remove tracking parameter in query string
|
|
|
|
'uri' => $itemUrl->withQueryString(null)->__toString(),
|
|
|
|
|
2022-11-17 20:06:35 +03:00
|
|
|
'author' => $account . '@rumble.com',
|
|
|
|
'content' => defaultLinkTo($video, self::URI)->innertext,
|
|
|
|
];
|
2024-08-23 18:09:17 +03:00
|
|
|
|
2023-12-21 11:18:21 +03:00
|
|
|
$time = $video->find('time', 0);
|
|
|
|
if ($time) {
|
|
|
|
$publishedAt = new \DateTimeImmutable($time->getAttribute('datetime'));
|
|
|
|
$item['timestamp'] = $publishedAt->getTimestamp();
|
|
|
|
}
|
|
|
|
$this->items[] = $item;
|
2022-11-17 20:06:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
2024-07-29 18:53:14 +03:00
|
|
|
if ($this->getInput('account')) {
|
|
|
|
return 'Rumble.com - ' . $this->getInput('account');
|
|
|
|
}
|
|
|
|
return self::NAME;
|
2022-11-17 20:06:35 +03:00
|
|
|
}
|
|
|
|
}
|