Add all HLS playlist items from player options
This commit is contained in:
parent
f81cadd6d1
commit
7a27725d6d
|
@ -21,29 +21,26 @@ function parse()
|
||||||
|
|
||||||
local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);')
|
local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);')
|
||||||
if playerOptionsJson then
|
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 playerOptions = dkjson.decode(playerOptionsJson)
|
||||||
local playlistItem = tables.find(playerOptions.playlist, function(playlistItem)
|
local playlistItems = tables.filter(playerOptions.playlist, function(playlistItem)
|
||||||
return playlistItem.type == 'hls'
|
return playlistItem.type == 'hls'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not playlistItem then
|
log.dbg('Number of playlist items:', #playlistItems)
|
||||||
log.warn('Cannot find playlist item of type hls in player options json:', playerOptionsJson)
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local params = tables.map(tables.toMap(vlc.path:gmatch('[?&]([^=]+)=([^&]*)')), function(param)
|
local params = tables.map(tables.toMap(vlc.path:gmatch('[?&]([^=]+)=([^&]*)')), function(param)
|
||||||
return vlc.strings.decode_uri(param)
|
return vlc.strings.decode_uri(param)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
return tables.map(playlistItems, function(playlistItem)
|
||||||
return {
|
return {
|
||||||
{
|
|
||||||
path = vlc.access .. ':' .. playlistItem.file,
|
path = vlc.access .. ':' .. playlistItem.file,
|
||||||
title = params.title,
|
title = params.title,
|
||||||
arturl = params.bgimage
|
arturl = params.bgimage
|
||||||
}
|
}
|
||||||
}
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
log.dbg('Cannot find player options json, finding embedded players');
|
log.dbg('Cannot find player options json, finding embedded players');
|
||||||
|
@ -138,3 +135,14 @@ function tables.map(values, transform)
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
end
|
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
|
||||||
|
|
Loading…
Reference in New Issue