From 8970ff6d495ee362098545b8f4a075ebda5d8099 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Mon, 19 Jul 2010 14:01:46 +0400 Subject: [PATCH] Fix MPORA lua playlist script. --- share/lua/playlist/mpora.lua | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/share/lua/playlist/mpora.lua b/share/lua/playlist/mpora.lua index 1144685aa9..8282f761b4 100644 --- a/share/lua/playlist/mpora.lua +++ b/share/lua/playlist/mpora.lua @@ -42,11 +42,34 @@ function parse() if string.match( line, "filmID" ) then _,_,video = string.find( line, "var filmID = \'(.*)\';") - table.insert( p, { path = "http://cdn0.mpora.com/play/video/"..video.."/mp4/"; name = name; arturl = arturl } ) - end - if string.match( line, "definitionLink hd" ) then - table.insert( p, { path = "http://cdn0.mpora.com/play/video/"..video.."_hd/mp4/"; name = name.." (HD)", arturl = arturl } ) end + end + + if not name or not arturl or not video then return nil end + + -- Try and get URL for SD video. + sd = vlc.stream("http://api.mpora.com/tv/player/playlist/vid/"..video.."/") + if not sd then return nil end + page = sd:read( 65653 ) + sdurl = string.match( page, "url=\"(.*)\" />") + page = nil + + table.insert( p, { path = sdurl; name = name; arturl = arturl; } ) + + -- Try and check if HD video is available. + checkhd = vlc.stream("http://api.mpora.com/tv/player/load/vid/"..video.."/platform/video/domain/video.mpora.com/" ) + if not checkhd then return nil end + page = checkhd:read( 65653 ) + hashd = tonumber( string.match( page, "(%d)" ) ) + page = nil + + if hashd then + hd = vlc.stream("http://api.mpora.com/tv/player/playlist/vid/"..video.."/hd/true/") + page = hd:read( 65653 ) + hdurl = string.match( page, "url=\"(.*)\" />") + table.insert( p, { path = hdurl; name = name.." (HD)"; arturl = arturl } ) + end + return p end -- 2.39.2