2 Translate Daily Motion video webpages URLs to the corresponding
7 Copyright © 2007 the VideoLAN team
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 return vlc.access == "http"
27 and string.match( vlc.path, "dailymotion." )
28 and string.match( vlc.peek( 2048 ), "<!DOCTYPE.*video_type" )
31 function find( haystack, needle )
32 local _,_,ret = string.find( haystack, needle )
43 vlc.msg.err("Couldn't extract the video URL from dailymotion")
46 if string.match( line, "\"sequence\",")
48 line = vlc.strings.decode_uri(line):gsub("\\/", "/")
50 arturl = find( line, "\"videoPreviewURL\":\"([^\"]*)\"")
51 name = find( line, "\"videoTitle\":\"([^\"]*)\"")
52 description = find( line, "\"videoDescription\":\"([^\"]*)\"")
54 --[[ we get a list of different streams available, at various codecs
57 Ideally, VLC would propose the different streams available,
58 codecs and resolutions (the resolutions are part of the URL)
60 For now we just built a list of preferred codecs : lowest value
61 means highest priority
64 -- FIXME: the hd/hq versions (in mp4) cause a lot of seeks,
65 -- for now we only get the sd (in flv) URL
67 -- if not path then path = find( line, "\"hqURL\":\"([^\"]*)\"") end
68 -- if not path then path = find( line, "\"hdURL\":\"([^\"]*)\"") end
69 if not path then path = find( line, "\"sdURL\":\"([^\"]*)\"") end
71 return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }