]> git.sesse.net Git - vlc/blobdiff - share/lua/playlist/canalplus.lua
Fix rc intf.
[vlc] / share / lua / playlist / canalplus.lua
index a83ad92144b8b6ac9c942bcae37280e97c5bf025..0b0af9a80bd3f119a8efbc7cc4d607d63b1e1e24 100644 (file)
@@ -1,7 +1,7 @@
 --[[
  $Id: $
 
- Copyright © 2007 the VideoLAN team
+ Copyright (c) 2007 the VideoLAN team
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -26,23 +26,24 @@ end
 -- Parse function.
 function parse()
     p = {}
-    --vlc.msg_dbg( vlc.path )
-    if string.match( vlc.path, "www.canalplus.fr/index.php%?pid=" )
+    --vlc.msg.dbg( vlc.path )
+    if string.match( vlc.path, "www.canalplus.fr/.*%?pid=.*" )
     then -- This is the HTML page's URL
+        local _,_,pid = string.find( vlc.path, "pid(%d-)%-" )
         local id, name, description, arturl
         while true do
             -- Try to find the video's title
             local line = vlc.readline()
             if not line then break end
-            -- vlc.msg_dbg( line )
+            -- vlc.msg.dbg( line )
             if string.match( line, "aVideos" ) then
                 if string.match( line, "CONTENT_ID.*=" ) then
-                    id = string.gsub( line, "^.*\"(.-)\".*$", "%1" )
+                    _,_,id = string.find( line, "\"(.-)\"" )
                 elseif string.match( line, "CONTENT_VNC_TITRE" ) then
-                    arturl = string.gsub( line, "^.*src=\"(.-)\".*$", "%1" )
-                    name = string.gsub( line, "^.*alt=\"(.-)\".*$", "%1" )
+                    _,_,arturl = string.find( line, "src=\"(.-)\"" )
+                    _,_,name = string.find( line, "title=\"(.-)\"" )
                 elseif string.match( line, "CONTENT_VNC_DESCRIPTION" ) then
-                    description = string.gsub( line, "^.*\"(.-)\".*$", "%1" )
+                    _,_,description = string.find( line, "\"(.-)\"" )
                 end
                 if id and string.match( line, "new Array" ) then
                     add_item( p, id, name, description, arturl )
@@ -61,10 +62,9 @@ function parse()
         while true do
             local line = vlc.readline()
             if not line then break end
-            --vlc.msg_dbg( line )
-            if string.match( line, "<hi>" ) then
-                local path = string.gsub( line, "^.*%[(.-)%].*$", "%1" )
-                vlc.msg_err("Path is: " .. tostring( path ) )
+            --vlc.msg.dbg( line )
+            if string.match( line, "<hi" ) then
+                local _,_,path = string.find( line, "%[(http.-)%]" )
                 return { { path = path } }
             end
         end
@@ -72,14 +72,15 @@ function parse()
 end
 
 function get_url_param( url, name )
-    return string.gsub( url, "^.*[&?]"..name.."=([^&]*).*$", "%1" )
+    local _,_,ret = string.find( url, "[&?]"..name.."=([^&]*)" )
+    return ret
 end
 
 function add_item( p, id, name, description, arturl )
-    --[[vlc.msg_dbg( "id: " .. tostring(id) )
-    vlc.msg_dbg( "name: " .. tostring(name) )
-    vlc.msg_dbg( "arturl: " .. tostring(arturl) )
-    vlc.msg_dbg( "description: " .. tostring(description) )
+    --[[vlc.msg.dbg( "id: " .. tostring(id) )
+    vlc.msg.dbg( "name: " .. tostring(name) )
+    vlc.msg.dbg( "arturl: " .. tostring(arturl) )
+    vlc.msg.dbg( "description: " .. tostring(description) )
     --]]
     --local path = "http://www.canalplus.fr/flash/xml/configuration/configuration-embed-video-player.php?xmlParam="..id.."-"..get_url_param(vlc.path,"pid")
     local path = "http://www.canalplus.fr/flash/xml/module/embed-video-player/embed-video-player.php?video_id="..id.."&pid="..get_url_param(vlc.path,"pid")