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