Skip to content

Commit

Permalink
[RumbleBridge] Facelift, Validation, & Livestreams (#4160)
Browse files Browse the repository at this point in the history
* [RumbleBridge] Facelift+media types (livestreams)

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

* [RumbleBridge] lint
  • Loading branch information
NotsoanoNimus authored Jul 29, 2024
1 parent 955fb6f commit 6d81d6d
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions bridges/RumbleBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

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 = [
[
'account' => [
'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',
],
],
]
];
Expand All @@ -30,12 +34,28 @@ public function collectData()
{
$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);
Expand All @@ -57,6 +77,9 @@ public function collectData()

public function getName()
{
return 'Rumble.com ' . $this->getInput('account');
if ($this->getInput('account')) {
return 'Rumble.com - ' . $this->getInput('account');
}
return self::NAME;
}
}

0 comments on commit 6d81d6d

Please sign in to comment.