]> git.sesse.net Git - vlc/blob - share/luaplaylist/dailymotion.lua
Fix the dailymotion lua script.
[vlc] / share / luaplaylist / dailymotion.lua
1 -- $Id$
2
3 --[[
4     Translate Daily Motion video webpages URLs to the corresponding
5     FLV URL.
6 --]]
7
8 -- Probe function.
9 function probe()
10     return vlc.access == "http"
11         and string.match( vlc.path, "dailymotion.com" ) 
12         and string.match( vlc.peek( 256 ), "<!DOCTYPE.*<title>Video " )
13 end
14
15 -- Parse function.
16 function parse()
17     while true
18     do 
19         line = vlc.readline()
20         if not line then break end
21         if string.match( line, "param name=\"flashvars\" value=\".*url=http" )
22         then
23             path = vlc.decode_uri( string.gsub( line, "^.*param name=\"flashvars\" value=\".*url=(http[^&]*).*$", "%1" ) )
24         end
25         --[[ if string.match( line, "<title>" )
26         then
27             title = vlc.decode_uri( string.gsub( line, "^.*<title>([^<]*).*$", "%1" ) )
28         end ]]
29         if string.match( line, "<meta name=\"description\"" )
30         then
31             name = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"%w+ (.*) %w+ %w+ %w+ %w+ Videos\..*$", "%1" ) )
32             description = vlc.resolve_xml_special_chars( string.gsub( line, "^.*name=\"description\" content=\"%w+ .* %w+ %w+ %w+ %w+ Videos\. ([^\"]*)\".*$", "%1" ) )
33         end
34         if string.match( line, "<link rel=\"thumbnail\"" )
35         then
36             arturl = string.gsub( line, "^.*\"thumbnail\" type=\"([^\"]*)\".*$", "http://%1" ) -- looks like the dailymotion people mixed up type and href here ...
37         end
38         if path and name and description and arturl then break end
39     end
40     return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
41 end