Changed patterns to be more generic

This commit is contained in:
Tibor Baksa 2017-09-10 17:22:25 +02:00
parent 27a6a17c07
commit b15dc2be32
1 changed files with 5 additions and 5 deletions

View File

@ -87,7 +87,7 @@ end
function Parser:path(playerUrl) function Parser:path(playerUrl)
local playerPageSource = streams.readAll(vlc.stream(playerUrl)) local playerPageSource = streams.readAll(vlc.stream(playerUrl))
local path = playerPageSource:match('"file": *"([^"]+)"') local path = playerPageSource:match('"file":%s*"(.-)"')
if path then if path then
return urls.normalize(path) return urls.normalize(path)
end end
@ -98,13 +98,13 @@ function VideoParser:playerUrls(pageSource)
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":"([^"]+)"')) local tokens = tables.collect(pageSource:gmatch('"token":%s*"(.-)"'))
return tables.map(playerUrl, tokens) return tables.map(playerUrl, tokens)
end end
function VideoParser:playListItem(path, pageSource) function VideoParser:playListItem(path, pageSource)
local function findProperty(property) local function findProperty(property)
return pageSource:match('<meta property="og:' .. property .. '" content="([^"]+)"/>') return pageSource:match('<meta%s+property=["\']og:' .. property .. '["\']%s+content=["\'](.-)["\']%s*/?>')
end end
return { return {
@ -117,7 +117,7 @@ function VideoParser:playListItem(path, pageSource)
end end
function LiveStreamParser:playerUrls(pageSource) function LiveStreamParser:playerUrls(pageSource)
local streamId = pageSource:match('"streamId":"([^"]+)"') local streamId = pageSource:match('"streamId":%s*"(.-)"')
if not streamId then if not streamId then
return {} return {}
end end
@ -128,7 +128,7 @@ end
function LiveStreamParser:playListItem(path, pageSource) function LiveStreamParser:playListItem(path, pageSource)
return { return {
path = path, path = path,
title = pageSource:match('<title>(.+)</title>'), title = pageSource:match('<title>(.-)</title>'),
url = protocol .. vlc.path url = protocol .. vlc.path
} }
end end