[vlc-commits] youtube.lua: support live streams
Pierre Ynard
git at videolan.org
Wed Oct 10 01:21:28 CEST 2012
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed Oct 10 01:20:48 2012 +0200| [64e30497fa764f680c2b235757e49f6c83b85028] | committer: Pierre Ynard
youtube.lua: support live streams
This could use a bit more testing than a single video
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64e30497fa764f680c2b235757e49f6c83b85028
---
share/lua/playlist/youtube.lua | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index aef5d28..8d4144c 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -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
@@ -210,6 +220,16 @@ function parse()
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 { }
end
More information about the vlc-commits
mailing list