3 -- Helper function to get a parameter's value in a URL
4 function get_url_param( url, name )
5 return string.gsub( vlc.path, "^.*"..name.."=([^&]*).*$", "%1" )
10 return vlc.access == "http"
11 and string.match( vlc.path, "youtube.com" )
12 and ( string.match( vlc.path, "watch%?v=" )
13 or string.match( vlc.path, "watch_fullscreen%?video_id=" )
14 or string.match( vlc.path, "p.swf" )
15 or string.match( vlc.path, "player2.swf" ) )
20 if string.match( vlc.path, "watch%?v=" )
21 then -- This is the HTML page's URL
23 -- Try to find the video's title
25 if not line then break end
26 if string.match( line, "<meta name=\"title\"" ) then
27 name = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
29 if string.match( line, "<meta name=\"description\"" ) then
30 description = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
32 if string.match( line, "subscribe_to_user=" ) then
33 artist = string.gsub( line, ".*subscribe_to_user=([^&]*).*", "%1" )
35 if string.match( line, "player2.swf" ) then
36 video_id = string.gsub( line, ".*BASE_YT_URL=http://youtube.com/&video_id=([^\"]*).*", "%1" )
38 if name and description and artist and video_id then break end
40 return { { path = "http://www.youtube.com/get_video.php?video_id="..video_id; name = name; description = description; artist = artist } }
41 else -- This is the flash player's URL
42 if string.match( vlc.path, "title=" ) then
43 name = get_url_param( vlc.path, "title" )
45 return { { path = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ); name = name } }