2 Translate Daily Motion video webpages URLs to the corresponding
7 Copyright © 2007-2011 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.
24 function get_prefres()
26 if vlc.var and vlc.var.inherit then
27 prefres = vlc.var.inherit(nil, "preferred-resolution")
28 if prefres == nil then
37 return vlc.access == "http"
38 and string.match( vlc.path, "www.dailymotion.com/video" )
41 function find( haystack, needle )
42 local _,_,ret = string.find( haystack, needle )
48 prefres = get_prefres()
55 if string.match( line, "sequence=")
57 line = vlc.strings.decode_uri(line):gsub("\\/", "/")
59 arturl = find( line, "\"videoPreviewURL\":\"([^\"]*)\"")
60 name = find( line, "\"videoTitle\":\"([^\"]*)\"")
62 name = string.gsub( name, "+", " " )
64 description = find( line, "\"videoDescription\":\"([^\"]*)\"")
66 description = string.gsub( description, "+", " " )
69 for _,param in ipairs({ "hd1080URL", "hd720URL", "hqURL", "sdURL", "video_url" }) do
70 path = string.match( line, "\""..param.."\":\"([^\"]*)\"" )
72 path = vlc.strings.decode_uri(path)
76 height = string.match( path, "/cdn/%w+%-%d+x(%d+)/video/" )
78 height = string.match( param, "(%d+)" )
80 if not height or tonumber(height) <= prefres then
90 return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
94 vlc.msg.err("Couldn't extract the video URL from dailymotion")