1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-01-17 06:08:27 +01:00

[RumbleBridge] Facelift, Validation, & Livestreams (#4160)

* [RumbleBridge] Facelift+media types (livestreams)

* [RumbleBridge] Remove 'required' from list input.

* [RumbleBridge] lint
This commit is contained in:
Zack Puhl 2024-07-29 11:53:14 -04:00 committed by GitHub
parent 955fb6f315
commit 6d81d6d306
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,10 +2,10 @@
class RumbleBridge extends BridgeAbstract class RumbleBridge extends BridgeAbstract
{ {
const NAME = 'rumble.com bridge'; const NAME = 'Rumble.com Bridge';
const URI = 'https://rumble.com'; const URI = 'https://rumble.com/';
const DESCRIPTION = 'Fetches the latest channel/user videos'; const DESCRIPTION = 'Fetches the latest channel/user videos and livestreams.';
const MAINTAINER = 'dvikan'; const MAINTAINER = 'dvikan, NotsoanoNimus';
const CACHE_TIMEOUT = 60 * 60; // 1h const CACHE_TIMEOUT = 60 * 60; // 1h
const PARAMETERS = [ const PARAMETERS = [
[ [
@ -13,15 +13,19 @@ class RumbleBridge extends BridgeAbstract
'name' => 'Account', 'name' => 'Account',
'type' => 'text', 'type' => 'text',
'required' => true, 'required' => true,
'title' => 'Name of the target account to create into a feed.',
'defaultValue' => 'bjornandreasbullhansen', 'defaultValue' => 'bjornandreasbullhansen',
], ],
'type' => [ 'type' => [
'name' => 'Account Type',
'type' => 'list', 'type' => 'list',
'name' => 'Type', 'title' => 'The type of profile to create a feed from.',
'values' => [ 'values' => [
'Channel' => 'channel', 'Channel (All)' => 'channel',
'User' => 'user', 'Channel Videos' => 'channel-videos',
] 'Channel Livestreams' => 'channel-livestream',
'User (All)' => 'user',
],
], ],
] ]
]; ];
@ -30,12 +34,28 @@ class RumbleBridge extends BridgeAbstract
{ {
$account = $this->getInput('account'); $account = $this->getInput('account');
$type = $this->getInput('type'); $type = $this->getInput('type');
$url = self::getURI();
if ($type === 'channel') { if (!preg_match('#^[\w\-_.@]+$#', $account) || strlen($account) > 64) {
$url = "https://rumble.com/c/$account"; throw new \Exception('Invalid target account.');
} }
if ($type === 'user') {
$url = "https://rumble.com/user/$account"; 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.');
} }
$dom = getSimpleHTMLDOM($url); $dom = getSimpleHTMLDOM($url);
@ -57,6 +77,9 @@ class RumbleBridge extends BridgeAbstract
public function getName() public function getName()
{ {
return 'Rumble.com ' . $this->getInput('account'); if ($this->getInput('account')) {
return 'Rumble.com - ' . $this->getInput('account');
}
return self::NAME;
} }
} }