Check if parsing the player page before finding the player options

This commit is contained in:
Tibor Baksa 2023-11-18 00:34:18 +01:00
parent f340ef11af
commit 62565c10f2
1 changed files with 11 additions and 4 deletions

View File

@ -19,9 +19,16 @@ end
function parse() function parse()
local pageSource = streams.readAll(vlc) local pageSource = streams.readAll(vlc)
if vlc.path:match('player%.mediaklikk%.hu') then
log.dbg('Player loaded, finding player options json')
local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);') local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);')
if playerOptionsJson then if not playerOptionsJson then
log.dbg('Found player options json, finding playlist items of type hls') log.warn('Cannot find player options json')
return nil
end
log.dbg('Finding playlist items of type hls')
local playerOptions = dkjson.decode(playerOptionsJson) local playerOptions = dkjson.decode(playerOptionsJson)
local playlistItems = tables.filter(playerOptions.playlist, function(playlistItem) local playlistItems = tables.filter(playerOptions.playlist, function(playlistItem)
@ -43,7 +50,7 @@ function parse()
end) end)
end end
log.dbg('Cannot find player options json, finding embedded players'); log.dbg('Finding embedded players');
local playerSetupJsons = tables.toArray(pageSource:gmatch('mtva_player_manager%.player%(document%.getElementById%("player_%d+_%d+"%), (%b{})%);')); local playerSetupJsons = tables.toArray(pageSource:gmatch('mtva_player_manager%.player%(document%.getElementById%("player_%d+_%d+"%), (%b{})%);'));