Skip to content

Commit

Permalink
Add Rumble support
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowsun™ authored and Shadowsun™ committed Nov 28, 2023
1 parent d11267b commit 87b38f6
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
Binary file added public/search/images/logos/rumble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion public/search/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ <h1>Share media from one of the selected services</h1>
onclick="selectService(this);" onmouseover="hoverService();">&nbsp;</span>

<span class="media-service subtext logo-yugen" data-href="https://yugenanime.tv/"
onclick="selectService(this);" onmouseover="hoverService();">&nbsp;</span>
onclick="selectService(this);" onmouseover="hoverService();">YugenAnime</span>

<span class="media-service subtext logo-rumble" data-href="https://rumble.com/"
onclick="selectService(this);" onmouseover="hoverService();">Rumble</span>

<span class="media-service subtext logo-ru" data-href="./ru.html"
onclick="selectService(this);" onmouseover="hoverService();">Российские потоки</span>
Expand Down
5 changes: 5 additions & 0 deletions public/search/styles/request.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ h1 {
}
.logo-yugen {
background-image: url(../images/logos/yugen.png);
background-size: 50px;
}
.logo-rumble {
background-image: url(../images/logos/rumble.png);
background-size: 50px;
}
.logo-vk {
background-image: url(../images/logos/vk.png);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
local SERVICE = {}

SERVICE.Name = "Rumble"
SERVICE.IsTimed = true

SERVICE.Dependency = DEPENDENCY_COMPLETE

local API_URL = "https://rumble.com/api/Media/oembed.json?url=https://rumble.com/%s"

function SERVICE:Match( url )
return url.host and url.host:match("rumble.com")
end

if (CLIENT) then
local THEATER_JS = [[
var checkerInterval = setInterval(function() {
var player = document.getElementsByTagName('video')[0];
if (!!player && player.paused == false && player.readyState == 4) {
if (player.muted) {player.muted = false}
clearInterval(checkerInterval);
document.body.style.backgroundColor = "black";
window.cinema_controller = player;
exTheater.controllerReady();
}
}, 50);
]]

function SERVICE:LoadProvider( Video, panel )

local function onFail(msg)
LocalPlayer():ChatPrint(("Rumble: %s"):format(msg))
end

local url = API_URL:format( Video:Data() ) .. ".html"
self:Fetch( url, function( body, length, headers, code )
local response = util.JSONToTable(body)
if not response then
return onFail("API Error")
end

local startTime = math.Round(CurTime() - Video:StartTime())
local embed = response.html:match("(https://rumble.com/embed/[%a%d-_]+/)")
.. "?pub=7a20&rel=5&autoplay=2"
.. (self.IsTimed and "&t=" .. startTime or "" )

panel:OpenURL(embed)
panel.OnDocumentReady = function(pnl)
self:LoadExFunctions( pnl )
pnl:QueueJavascript(THEATER_JS)
end

end, onFail)

end
end

function SERVICE:GetURLInfo( url )

if url.path then
local data = url.path:match("/([%a%d%p-_]+).html")
if ( data ) then return { Data = data } end
end

return false
end

function SERVICE:GetVideoInfo( data, onSuccess, onFailure )

local onReceive = function( body, length, headers, code )
local response = util.JSONToTable(body)
if not response then
return onFailure( "Theater_RequestFailed" )
end

local info = {}
info.title = response.title
info.thumbnail = response.thumbnail_url

if response.duration == 0 then
info.type = "rumblelive"
info.duration = 0
else
info.duration = response.duration
end

if onSuccess then
pcall(onSuccess, info)
end

end

local url = API_URL:format( data ) .. ".html"
self:Fetch( url, onReceive, onFailure )

end

theater.RegisterService( "rumble", SERVICE )

theater.RegisterService( "rumblelive", {
Name = "Rumble Live",
IsTimed = false,
Hidden = true,
LoadProvider = CLIENT and SERVICE.LoadProvider or function() end
} )

0 comments on commit 87b38f6

Please sign in to comment.