Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
|
34e39eb3c1 | |
|
bce8b7ca8f | |
|
62565c10f2 | |
|
f340ef11af | |
|
7a27725d6d | |
|
f81cadd6d1 | |
|
8b6793c6a7 |
15
README.md
15
README.md
|
@ -1,4 +1,4 @@
|
|||
# vlc-mediaklikk
|
||||
# vlc-mediaklikk-video
|
||||
VLC playlist parser for MédiaKlikk videos and video streams
|
||||
|
||||
## Installation
|
||||
|
@ -14,10 +14,6 @@ Copy [mediaklikk-video.lua](mediaklikk-video.lua) to [VLC Lua playlist scripts](
|
|||
* Mac OS X: `~/Library/Application Support/org.videolan.vlc/lua/playlist/`
|
||||
* Windows: `%APPDATA%\vlc\lua\playlist\`
|
||||
|
||||
## From addons.videolan.org
|
||||
|
||||
This playlist parser is also [available on addons.videolan.org](https://addons.videolan.org/p/1190582/).
|
||||
|
||||
## Supported sites
|
||||
|
||||
### Videos
|
||||
|
@ -26,9 +22,14 @@ This playlist parser is also [available on addons.videolan.org](https://addons.v
|
|||
* [mediaklikk.hu](https://www.mediaklikk.hu/)
|
||||
|
||||
### Video streams
|
||||
* [M1](https://www.mediaklikk.hu/m1-elo)
|
||||
* [M1](https://hirado.hu/elo/m1)
|
||||
* [M2](https://www.mediaklikk.hu/m2-elo)
|
||||
* [M4](https://www.mediaklikk.hu/m4-elo)
|
||||
* [M4 Sport](https://m4sport.hu/elo/mtv4live)
|
||||
* [M4 Sport +](https://m4sport.hu/elo/mtv4plus)
|
||||
* [M5](https://www.mediaklikk.hu/m5-elo)
|
||||
* [Duna](https://www.mediaklikk.hu/duna-elo)
|
||||
* [Duna World](https://www.mediaklikk.hu/duna-world-elo)
|
||||
|
||||
## On addons.videolan.org
|
||||
|
||||
This playlist parser is also [available on addons.videolan.org](https://addons.videolan.org/p/1190582/).
|
||||
|
|
|
@ -11,16 +11,48 @@ local urlPatterns = {
|
|||
}
|
||||
|
||||
function probe()
|
||||
return vlc.access:match('https?')
|
||||
and tables.find(urlPatterns, function(pattern)
|
||||
return vlc.path:match(pattern)
|
||||
end)
|
||||
and not vlc.path:match('player%.mediaklikk%.hu')
|
||||
return vlc.access:match('https?') and tables.find(urlPatterns, function(pattern)
|
||||
return vlc.path:match(pattern)
|
||||
end)
|
||||
end
|
||||
|
||||
function parse()
|
||||
local pageSource = streams.readAll(vlc)
|
||||
local playerSetupJsons = tables.collect(pageSource:gmatch('mtva_player_manager%.player%(document%.getElementById%("player_%d+_%d+"%), (%b{})%);'));
|
||||
|
||||
if vlc.path:match('player%.mediaklikk%.hu') then
|
||||
log.dbg('Player loaded, finding player options json')
|
||||
|
||||
local playerOptionsJson = pageSource:match('pl.setup%( (%b{}) %);')
|
||||
if not playerOptionsJson then
|
||||
log.warn('Cannot find player options json')
|
||||
return nil
|
||||
end
|
||||
|
||||
log.dbg('Finding playlist items of type hls')
|
||||
|
||||
local playerOptions = dkjson.decode(playerOptionsJson)
|
||||
local playlistItems = tables.filter(playerOptions.playlist, function(playlistItem)
|
||||
return playlistItem.type == 'hls'
|
||||
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 tables.map(playlistItems, function(playlistItem)
|
||||
return {
|
||||
path = playlistItem.file:gsub('^//', vlc.access .. '://'),
|
||||
title = params.title,
|
||||
arturl = params.bgimage
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
log.dbg('Finding embedded players');
|
||||
|
||||
local playerSetupJsons = tables.toArray(pageSource:gmatch('mtva_player_manager%.player%(document%.getElementById%("player_%d+_%d+"%), (%b{})%);'));
|
||||
|
||||
log.dbg('Number of players:', #playerSetupJsons)
|
||||
|
||||
|
@ -33,27 +65,21 @@ function parse()
|
|||
return nil
|
||||
end
|
||||
|
||||
local playerUrl = vlc.access .. '://player.mediaklikk.hu/playernew/player.php?video=' .. video
|
||||
local title = playerSetup.title or openGraph.property(pageSource, 'title')
|
||||
local arturl = (playerSetup.bgImage and vlc.access .. ':' .. playerSetup.bgImage) or openGraph.property(pageSource, 'image')
|
||||
local playerUrl = vlc.access .. '://player.mediaklikk.hu/playernew/player.php?video=' .. video ..
|
||||
((title and '&title=' .. vlc.strings.encode_uri_component(title)) or '') ..
|
||||
((arturl and '&bgimage=' .. vlc.strings.encode_uri_component(arturl)) or '')
|
||||
|
||||
log.dbg('Loading player:', playerUrl)
|
||||
|
||||
local playerSource = streams.readAll(vlc.stream(playerUrl))
|
||||
local playerOptionsJson = playerSource:match('pl.setup%( (%b{}) %);')
|
||||
local playerOptions = dkjson.decode(playerOptionsJson)
|
||||
local playlistItem = tables.find(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
|
||||
|
||||
return {
|
||||
path = vlc.access .. ':' .. playlistItem.file,
|
||||
title = playerSetup.title or openGraph.property(pageSource, 'title'),
|
||||
description = openGraph.property(pageSource, 'description'),
|
||||
arturl = (playerSetup.bgImage and vlc.access .. ':' .. playerSetup.bgImage) or openGraph.property(pageSource, 'image')
|
||||
path = playerUrl,
|
||||
title = title,
|
||||
arturl = arturl,
|
||||
options = {
|
||||
'http-referrer=' .. vlc.access .. '://' .. vlc.path
|
||||
}
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
@ -82,7 +108,7 @@ function streams.readAll(s)
|
|||
end
|
||||
end
|
||||
|
||||
return table.concat(tables.collect(iterator, 1024, nil));
|
||||
return table.concat(tables.toArray(iterator, 1024, nil));
|
||||
end
|
||||
|
||||
function tables.find(values, predicate)
|
||||
|
@ -93,7 +119,7 @@ function tables.find(values, predicate)
|
|||
end
|
||||
end
|
||||
|
||||
function tables.collect(iterator, state, initialValue)
|
||||
function tables.toArray(iterator, state, initialValue)
|
||||
local result = {}
|
||||
for value in iterator, state, initialValue do
|
||||
table.insert(result, value)
|
||||
|
@ -101,6 +127,14 @@ function tables.collect(iterator, state, initialValue)
|
|||
return result
|
||||
end
|
||||
|
||||
function tables.toMap(iterator, state, initialValue)
|
||||
local result = {}
|
||||
for key, value in iterator, state, initialValue do
|
||||
result[key] = value
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function tables.map(values, transform)
|
||||
local result = {}
|
||||
for key, value in pairs(values) do
|
||||
|
@ -108,3 +142,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
|
||||
|
|
Loading…
Reference in New Issue