]> git.sesse.net Git - vlc/commitdiff
youtube.lua: support live streams
authorPierre Ynard <linkfanel@yahoo.fr>
Tue, 9 Oct 2012 23:20:48 +0000 (01:20 +0200)
committerPierre Ynard <linkfanel@yahoo.fr>
Tue, 9 Oct 2012 23:20:48 +0000 (01:20 +0200)
This could use a bit more testing than a single video

share/lua/playlist/youtube.lua

index aef5d284c28f4fdd0c5b247b075bd8e8c279bdd9..8d4144c875967ffe5f0c3a51c8f61c24191213d8 100644 (file)
@@ -158,6 +158,16 @@ function parse()
                     url_map = string.gsub( url_map, "\\u0026", "&" )
                     path = pick_url( url_map, fmt )
                 end
+
+                if not path then
+                    -- If this is a live stream, the URL map will be empty
+                    -- and we get the URL from this field instead 
+                    local hlsvp = string.match( line, "\"hlsvp\": \"(.-)\"" )
+                    if hlsvp then
+                        hlsvp = string.gsub( hlsvp, "\\/", "/" )
+                        path = hlsvp
+                    end
+                end
             -- There is also another version of the parameters, encoded
             -- differently, as an HTML attribute of an <object> or <embed>
             -- tag; but we don't need it now
@@ -209,6 +219,16 @@ function parse()
             path = pick_url( url_map, fmt )
         end
 
+        if not path then
+            -- If this is a live stream, the URL map will be empty
+            -- and we get the URL from this field instead 
+            local hlsvp = string.match( line, "&hlsvp=([^&]*)" )
+            if hlsvp then
+                hlsvp = vlc.strings.decode_uri( hlsvp )
+                path = hlsvp
+            end
+        end
+
         if not path then
             vlc.msg.err( "Couldn't extract youtube video URL, please check for updates to this script" )
             return { }