]> git.sesse.net Git - vlc/blob - share/luaplaylist/dailymotion.lua
* dailymotion.lua: woops, forgot to include title fetching in previous version.
[vlc] / share / luaplaylist / dailymotion.lua
1 -- $Id$
2
3 -- Probe function.
4 function probe()
5     return vlc.access == "http"
6         and string.match( vlc.path, "dailymotion.com" ) 
7         and vlc.peek( 9 ) == "<!DOCTYPE"
8 end
9
10 -- Parse function.
11 function parse()
12     while true
13     do 
14         line = vlc.readline()
15         if not line then break end
16         if string.match( line, "param name=\"flashvars\" value=\"url=" )
17         then
18             url = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\"url=([^&]*).*$", "%1" ) )
19         end
20         if string.match( line, "<title>" )
21         then
22             title = vlc.decode_uri( string.gsub( line, "^.*<title>([^<]*).*$", "%1" ) )
23         end
24         if url and title then break end
25     end
26     return { { url = url; title = title } }
27 end