]> git.sesse.net Git - vlc/commitdiff
fix youtube lua probing, avoid infinite loops
authorRafaël Carré <funman@videolan.org>
Sun, 7 Oct 2007 17:54:41 +0000 (17:54 +0000)
committerRafaël Carré <funman@videolan.org>
Sun, 7 Oct 2007 17:54:41 +0000 (17:54 +0000)
homepage: use %? to represent '?'
other: probe is not successfull anymore for urls like http://10.0.0.1/get_video?xxxx&origin=youtube.com

share/luaplaylist/youtube.lua
share/luaplaylist/youtube_homepage.lua

index 48b4981fb4492178d62f9f1bee576eb1a9ce9c3f..9c3aa7f66101648e34e3931a55a11e4ebf316fb1 100644 (file)
@@ -16,14 +16,23 @@ end
 
 -- Probe function.
 function probe()
-    return vlc.access == "http"
-        and string.match( vlc.path, "youtube.com" ) 
-        and (  string.match( vlc.path, "watch%?v=" ) -- the html page
+    if vlc.access ~= "http" then
+        return false
+    end
+    youtube_site = string.match( string.sub( vlc.path, 1, 8 ), "youtube" )
+    if not youtube_site then
+        -- FIXME we should be using a builtin list of known youtube websites
+        -- like "fr.youtube.com", "uk.youtube.com" etc..
+        youtube_site = string.find( vlc.path, ".youtube.com" )
+        if youtube_site == nil then
+            return false
+        end
+    end
+    return (  string.match( vlc.path, "watch%?v=" ) -- the html page
             or string.match( vlc.path, "watch_fullscreen%?video_id=" ) -- the fullscreen page
             or string.match( vlc.path, "p.swf" ) -- the (old?) player url
             or string.match( vlc.path, "jp.swf" ) -- the (new?) player url (as of 24/08/2007)
-            or string.match( vlc.path, "player2.swf" ) -- another player url
-            or ( string.match( vlc.path, "get_video%?video_id=" ) and not string.match( vlc.path, "t=" ) ) ) -- the video url without the t= parameter which is mandatory (since 24/08/2007)
+            or string.match( vlc.path, "player2.swf" ) ) -- another player url
 end
 
 -- Parse function.
@@ -49,7 +58,7 @@ function parse()
                     base_yt_url = string.gsub( line, ".*BASE_YT_URL:'([^']*)'.*", "%1" )
                 end
                 t = string.gsub( line, ".*t:'([^']*)'.*", "%1" )
-                vlc.msg_err( t )
+                -- vlc.msg_err( t )
                 -- video_id = string.gsub( line, ".*&video_id:'([^']*)'.*", "%1" )
             end
             if name and description and artist --[[and video_id]] then break end
index 7a26de13cb1f8da42de1753ea5b1e1333f9487c9..4119ccd1ee545b31eef8bfc83943045ddb6df2a5 100644 (file)
@@ -4,7 +4,7 @@
 --]]
 
 function probe()
-    return vlc.access == "http" and ( string.match( vlc.path, "youtube.com/?$" ) or string.match( vlc.path, "youtube.com/browse" ) )
+    return vlc.access == "http" and ( string.match( vlc.path, "youtube.com/%?$" ) or string.match( vlc.path, "youtube.com/browse" ) )
 end
 
 function parse()