Skip to content

Commit

Permalink
Add all HLS playlist items from player options
Browse files Browse the repository at this point in the history
  • Loading branch information
tiborbaksa committed Nov 22, 2022
1 parent f81cadd commit 7a27725
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions mediaklikk-video.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,26 @@ function parse()

local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);')
if playerOptionsJson then
log.dbg('Found player options json, finding playlist item of type hls')
log.dbg('Found player options json, finding playlist items of type hls')

local playerOptions = dkjson.decode(playerOptionsJson)
local playlistItem = tables.find(playerOptions.playlist, function(playlistItem)
local playlistItems = tables.filter(playerOptions.playlist, function(playlistItem)
return playlistItem.type == 'hls'
end)

if not playlistItem then
log.warn('Cannot find playlist item of type hls in player options json:', playerOptionsJson)
return nil
end
log.dbg('Number of playlist items:', #playlistItems)

local params = tables.map(tables.toMap(vlc.path:gmatch('[?&]([^=]+)=([^&]*)')), function(param)
return vlc.strings.decode_uri(param)
end)

return {
{
return tables.map(playlistItems, function(playlistItem)
return {
path = vlc.access .. ':' .. playlistItem.file,
title = params.title,
arturl = params.bgimage
}
}
end)
end

log.dbg('Cannot find player options json, finding embedded players');
Expand Down Expand Up @@ -138,3 +135,14 @@ function tables.map(values, transform)
end
return result
end


function tables.filter(values, predicate)
local result = {}
for key, value in pairs(values) do
if predicate(value, key, values) then
result[key] = value
end
end
return result
end

0 comments on commit 7a27725

Please sign in to comment.