Implemented support for multiple videos on one page
This commit is contained in:
parent
9f9331752e
commit
3d0cf7e805
|
@ -52,24 +52,37 @@ end
|
||||||
function Parser:parse()
|
function Parser:parse()
|
||||||
local pageSource = streams.readAll(vlc)
|
local pageSource = streams.readAll(vlc)
|
||||||
|
|
||||||
log.dbg('Extracting Player URL...')
|
log.dbg('Extracting Player URLs...')
|
||||||
|
|
||||||
local playerUrl = self:playerUrl(pageSource)
|
local playerUrls = self:playerUrls(pageSource)
|
||||||
if not playerUrl then
|
if #playerUrls == 0 then
|
||||||
return noPlaylist('could not find Player URL')
|
return noPlaylist('could not find any Player URL')
|
||||||
end
|
end
|
||||||
|
|
||||||
log.dbg('Player URL:', playerUrl)
|
log.dbg('Player URLs:', unpack(playerUrls))
|
||||||
log.dbg('Extracting Path...')
|
log.dbg('Extracting Paths...')
|
||||||
|
|
||||||
|
local function findPath(playerUrl)
|
||||||
local path = self:path(playerUrl)
|
local path = self:path(playerUrl)
|
||||||
if not path then
|
if not path then
|
||||||
return noPlaylist('could not find Path')
|
log.warn('could not extract Path from', playerUrl)
|
||||||
end
|
end
|
||||||
|
|
||||||
log.dbg('Path:', path)
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
return {self:playListItem(path, pageSource)}
|
local paths = tables.map(findPath, playerUrls)
|
||||||
|
if #paths == 0 then
|
||||||
|
return noPlaylist('could not find any Path')
|
||||||
|
end
|
||||||
|
|
||||||
|
log.dbg('Paths:', unpack(paths))
|
||||||
|
|
||||||
|
local function playListItem(path)
|
||||||
|
return self:playListItem(path, pageSource)
|
||||||
|
end
|
||||||
|
|
||||||
|
return tables.map(playListItem, paths)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parser:path(playerUrl)
|
function Parser:path(playerUrl)
|
||||||
|
@ -80,11 +93,13 @@ function Parser:path(playerUrl)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function VideoParser:playerUrl(pageSource)
|
function VideoParser:playerUrls(pageSource)
|
||||||
local token = pageSource:match('"token":"([^"]+)"')
|
local function playerUrl(token)
|
||||||
if token then
|
|
||||||
return protocol .. 'player.mediaklikk.hu/player/player-external-vod-full.php?hls=1&token=' .. token
|
return protocol .. 'player.mediaklikk.hu/player/player-external-vod-full.php?hls=1&token=' .. token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tokens = tables.collect(pageSource:gmatch('"token":"([^"]+)"'))
|
||||||
|
return tables.map(playerUrl, tokens)
|
||||||
end
|
end
|
||||||
|
|
||||||
function VideoParser:playListItem(path, pageSource)
|
function VideoParser:playListItem(path, pageSource)
|
||||||
|
@ -101,11 +116,13 @@ function VideoParser:playListItem(path, pageSource)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function LiveStreamParser:playerUrl(pageSource)
|
function LiveStreamParser:playerUrls(pageSource)
|
||||||
local streamId = pageSource:match('"streamId":"([^"]+)"')
|
local streamId = pageSource:match('"streamId":"([^"]+)"')
|
||||||
if streamId then
|
if not streamId then
|
||||||
return protocol .. 'player.mediaklikk.hu/playernew/player.php?noflash=yes&video=' .. streamId
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return {protocol .. 'player.mediaklikk.hu/playernew/player.php?noflash=yes&video=' .. streamId}
|
||||||
end
|
end
|
||||||
|
|
||||||
function LiveStreamParser:playListItem(path, pageSource)
|
function LiveStreamParser:playListItem(path, pageSource)
|
||||||
|
@ -136,6 +153,14 @@ tables = {
|
||||||
table.insert(result, value)
|
table.insert(result, value)
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
|
end,
|
||||||
|
|
||||||
|
map = function(transform, values)
|
||||||
|
local result = {}
|
||||||
|
for key, value in ipairs(values) do
|
||||||
|
result[key] = transform(value, i, values)
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue