Compare commits

...

7 Commits

Author SHA1 Message Date
Tibor Baksa 34e39eb3c1 Update video streams 2023-11-18 00:57:32 +01:00
Tibor Baksa bce8b7ca8f Prepend protocol to stream URL when not provided 2023-11-18 00:50:09 +01:00
Tibor Baksa 62565c10f2 Check if parsing the player page before finding the player options 2023-11-18 00:45:21 +01:00
Tibor Baksa f340ef11af Update title in README 2023-11-18 00:45:10 +01:00
Tibor Baksa 7a27725d6d Add all HLS playlist items from player options 2022-11-22 21:22:09 +01:00
Tibor Baksa f81cadd6d1 Create separate playlist item for player URL and send referrer 2022-11-22 20:55:07 +01:00
Tibor Baksa 8b6793c6a7 Moved section about addons.videolan.org to the end of the README 2018-09-11 00:42:03 +02:00
2 changed files with 78 additions and 32 deletions

View File

@ -1,4 +1,4 @@
# vlc-mediaklikk # vlc-mediaklikk-video
VLC playlist parser for MédiaKlikk videos and video streams VLC playlist parser for MédiaKlikk videos and video streams
## Installation ## 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/` * Mac OS X: `~/Library/Application Support/org.videolan.vlc/lua/playlist/`
* Windows: `%APPDATA%\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 ## Supported sites
### Videos ### Videos
@ -26,9 +22,14 @@ This playlist parser is also [available on addons.videolan.org](https://addons.v
* [mediaklikk.hu](https://www.mediaklikk.hu/) * [mediaklikk.hu](https://www.mediaklikk.hu/)
### Video streams ### Video streams
* [M1](https://www.mediaklikk.hu/m1-elo) * [M1](https://hirado.hu/elo/m1)
* [M2](https://www.mediaklikk.hu/m2-elo) * [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) * [M5](https://www.mediaklikk.hu/m5-elo)
* [Duna](https://www.mediaklikk.hu/duna-elo) * [Duna](https://www.mediaklikk.hu/duna-elo)
* [Duna World](https://www.mediaklikk.hu/duna-world-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/).

View File

@ -11,16 +11,48 @@ local urlPatterns = {
} }
function probe() function probe()
return vlc.access:match('https?') return vlc.access:match('https?') and tables.find(urlPatterns, function(pattern)
and tables.find(urlPatterns, function(pattern) return vlc.path:match(pattern)
return vlc.path:match(pattern) end)
end)
and not vlc.path:match('player%.mediaklikk%.hu')
end end
function parse() function parse()
local pageSource = streams.readAll(vlc) 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) log.dbg('Number of players:', #playerSetupJsons)
@ -33,27 +65,21 @@ function parse()
return nil return nil
end 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) 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 { return {
path = vlc.access .. ':' .. playlistItem.file, path = playerUrl,
title = playerSetup.title or openGraph.property(pageSource, 'title'), title = title,
description = openGraph.property(pageSource, 'description'), arturl = arturl,
arturl = (playerSetup.bgImage and vlc.access .. ':' .. playerSetup.bgImage) or openGraph.property(pageSource, 'image') options = {
'http-referrer=' .. vlc.access .. '://' .. vlc.path
}
} }
end) end)
end end
@ -82,7 +108,7 @@ function streams.readAll(s)
end end
end end
return table.concat(tables.collect(iterator, 1024, nil)); return table.concat(tables.toArray(iterator, 1024, nil));
end end
function tables.find(values, predicate) function tables.find(values, predicate)
@ -93,7 +119,7 @@ function tables.find(values, predicate)
end end
end end
function tables.collect(iterator, state, initialValue) function tables.toArray(iterator, state, initialValue)
local result = {} local result = {}
for value in iterator, state, initialValue do for value in iterator, state, initialValue do
table.insert(result, value) table.insert(result, value)
@ -101,6 +127,14 @@ function tables.collect(iterator, state, initialValue)
return result return result
end 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) function tables.map(values, transform)
local result = {} local result = {}
for key, value in pairs(values) do for key, value in pairs(values) do
@ -108,3 +142,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