[vlc-commits] youtube.lua: clean up SWF URL handling

Pierre Ynard git at videolan.org
Sun Aug 7 10:54:54 CEST 2011


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Aug  7 10:53:37 2011 +0200| [b5573aef1aa000c3b9a730b96859184ec73abda0] | committer: Pierre Ynard

youtube.lua: clean up SWF URL handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b5573aef1aa000c3b9a730b96859184ec73abda0
---

 share/lua/playlist/youtube.lua |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index 95a7a43..36cccdf 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -51,16 +51,14 @@ function probe()
             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
+    return (  string.match( vlc.path, "/watch%?" ) -- the html page
+            or string.match( vlc.path, "/v/" ) -- video in swf player
+            or string.match( vlc.path, "/player2.swf" ) ) -- another player url
 end
 
 -- Parse function.
 function parse()
-    if string.match( vlc.path, "watch%?v=" )
+    if string.match( vlc.path, "/watch%?" )
     then -- This is the HTML page's URL
         -- fmt is the format of the video
         -- (cf. http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs)
@@ -109,32 +107,31 @@ function parse()
             end
         end
 
-        if not arturl then
-            arturl = get_arturl()
-        end
-
         if not path then
             vlc.msg.err( "Couldn't extract youtube video URL, please check for updates to this script" )
             return { }
         end
+
+        if not arturl then
+            arturl = get_arturl()
+        end
+
         return { { path = path; name = name; description = description; artist = artist; arturl = arturl } }
     else -- This is the flash player's URL
-        if string.match( vlc.path, "title=" ) then
-            name = vlc.strings.decode_uri(get_url_param( vlc.path, "title" ))
-        end
         video_id = get_url_param( vlc.path, "video_id" )
-        arturl = get_arturl( vlc.path, video_id )
+        if not video_id then
+            _,_,video_id = string.find( vlc.path, "/v/([^?]*)" )
+        end
+        if not video_id then
+            vlc.msg.err( "Couldn't extract youtube video URL" )
+            return { }
+        end
         fmt = get_url_param( vlc.path, "fmt" )
         if fmt then
             format = "&fmt=" .. fmt
         else
             format = ""
         end
-        if not string.match( vlc.path, "t=" ) then
-            -- This sucks, we're missing "t" which is now mandatory. Let's
-            -- try using another url
-            return { { path = "http://www.youtube.com/v/"..video_id; name = name; arturl = arturl } }
-        end
-        return { { path = "http://www.youtube.com/get_video.php?video_id="..video_id.."&t="..get_url_param( vlc.path, "t" )..format; name = name; arturl = arturl } }
+        return { { path = "http://www.youtube.com/watch?v="..video_id..format } }
     end
 end



More information about the vlc-commits mailing list