4 Copyright © 2009 the VideoLAN team
6 Authors: Konstantin Pavlov (thresh@videolan.org)
7 François Revol (revol@free.fr)
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, "vimeo.com/%d+$" )
39 -- do not match other addresses,
40 -- else we'll also try to decode the actual video url
45 agent = vlc.var.inherit(nil,"http-user-agent")
47 if string.match( string.lower(agent), ".*vlc.*" ) then
48 vlc.msg.dbg("Wrong agent, adapting...")
49 return { { path = vlc.access .. "://" .. vlc.path; options = {":http-user-agent=Mozilla/5.0" } } }
52 _,_,id = string.find( vlc.path, "vimeo.com/([0-9]*)")
53 prefres = get_prefres()
60 if not line then break end
61 if string.match( line, "{config:.*") then
63 while not string.match( line2, "}};") do
64 line2 = vlc.readline()
65 if not line2 then break end
69 -- Try to find the video's title
70 if string.match( line, "<meta property=\"og:title\"" ) then
71 _,_,name = string.find (line, "content=\"(.*)\">" )
73 if string.match( line, "{config:.*\"title\":\"" ) then
74 _,_,name = string.find (line, "\"title\":\"([^\"]*)\"," )
76 -- Try to find image for thumbnail
77 if string.match( line, "<meta property=\"og:image\"" ) then
78 _,_,arturl = string.find (line, "content=\"(.*)\">" )
80 if string.match( line, "<meta itemprop=\"thumbnailUrl\"" ) then
81 _,_,arturl = string.find (line, "content=\"(.*)\">" )
83 -- Try to find duration
84 if string.match( line, "{config:.*\"duration\":" ) then
85 _,_,duration = string.find (line, "\"duration\":([0-9]*)," )
87 -- Try to find request signature (needed to construct video url)
88 if string.match( line, "{config:.*\"signature\":" ) then
89 _,_,rsig = string.find (line, "\"signature\":\"([0-9a-f]*)\"," )
91 -- Try to find request signature time (needed to construct video url)
92 if string.match( line, "{config:.*\"timestamp\":" ) then
93 _,_,tstamp = string.find (line, "\"timestamp\":([0-9]*)," )
95 -- Try to find the available codecs
96 if string.match( line, "{config:.*,\"files\":{\"vp6\":" ) then
99 if string.match( line, "{config:.*,\"files\":{\"vp8\":" ) then
102 if string.match( line, "{config:.*,\"files\":{\"h264\":" ) then
105 -- Try to find whether video is HD actually
106 if string.match( line, "{config:.*,\"hd\":1" ) then
109 if string.match( line, "{config:.*\"height\":" ) then
110 _,_,height = string.find (line, "\"height\":([0-9]*)," )
112 if not line2 then break end
116 vlc.msg.err("unable to find codec info")
120 if ishd and ( not height or prefres < 0 or prefres >= tonumber(height) ) then
123 path = "http://player.vimeo.com/play_redirect?quality="..quality.."&codecs="..codec.."&clip_id="..id.."&time="..tstamp.."&sig="..rsig.."&type=html5_desktop_local"
124 return { { path = path; name = name; arturl = arturl; duration = duration } }