4 VLC Lua playlist modules should define two functions:
5 * probe(): returns true if we want to handle the playlist in this script
6 * parse(): read the incoming data and return playlist item(s)
7 The playlist is a table of playlist objects.
8 A playlist object has the following members:
9 .url: the item's full URL
10 .title: the item's title (OPTIONAL)
11 Invalid playlist items will be discarded by VLC.
13 VLC defines a global vlc object with the following members:
14 * vlc.path: the URL string (without the leading http:// or file:// element)
15 * vlc.access: the access used ("http" for http://, "file" for file://, etc.)
16 * vlc.peek( <int> ): return the first <int> characters from the playlist file.
17 * vlc.readline(): return a new line of playlist data on each call.
18 THIS FUNCTION SHOULD NOT BE USED IN peek().
19 * vlc.decode_uri( <string> ): decode %xy characters in a string.
20 * vlc.resolve_xml_special_chars( <string> ): decode &abc; characters in a string.
22 Lua scripts are tried in alphabetical order in the luaplaylist/ directory.
24 Lua documentation is available on http://www.lua.org .
26 All the Lua standard libraries are available.
29 -- Helper function to get a parameter's value in a URL
30 function get_url_param( url, name )
31 return string.gsub( vlc.path, "^.*"..name.."=([^&]*).*$", "%1" )
36 return vlc.access == "http"
37 and string.match( vlc.path, "youtube.com" )
38 and ( string.match( vlc.path, "watch%?v=" )
39 or string.match( vlc.path, "watch_fullscreen%?video_id=" )
40 or string.match( vlc.path, "p.swf" )
41 or string.match( vlc.path, "player2.swf" ) )
47 if string.match( vlc.path, "watch%?v=" )
48 then -- This is the HTML page's URL
49 p[1] = { url = string.gsub( vlc.path, "^(.*)watch%?v=([^&]*).*$", "http://%1v/%2" ) }
51 -- Try to find the video's title
53 if not line then break end
54 if string.match( line, "<meta name=\"title\"" ) then
55 p[1].title = string.gsub( line, "^.*content=\"([^\"]*).*$", "%1" )
59 else -- This is the flash player's URL
60 p[1] = { url = "http://www.youtube.com/get_video.php?video_id="..get_url_param( vlc.path, "video_id" ).."&t="..get_url_param( vlc.patch, "t" ) }
61 if string.match( vlc.path, "title=" ) then
62 p[1].title = get_url_param( vlc.path, "title" )