Commit 86486412 authored by François Revol's avatar François Revol Committed by Mirsal Ennaime

lua vimeo playlist: Use new vimeo API

The moogaloop flash urls are not valid anymore
Use the html5 API instead, which gives mp4 files.
Signed-off-by: default avatarMirsal Ennaime <mirsal@videolan.org>
parent 9cd19ad5
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
Copyright © 2009 the VideoLAN team Copyright © 2009 the VideoLAN team
Authors: Konstantin Pavlov (thresh@videolan.org) Authors: Konstantin Pavlov (thresh@videolan.org)
François Revol (revol@free.fr)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -34,57 +35,62 @@ end ...@@ -34,57 +35,62 @@ end
-- Probe function. -- Probe function.
function probe() function probe()
return vlc.access == "http" return vlc.access == "http"
and string.match( vlc.path, "vimeo.com/%d+" ) and string.match( vlc.path, "vimeo.com/%d+$" )
or string.match( vlc.path, "vimeo.com/moogaloop/load" ) -- do not match other addresses,
-- else we'll also try to decode the actual video url
end end
-- Parse function. -- Parse function.
function parse() function parse()
if string.match ( vlc.path, "vimeo.com/%d+" ) then if string.match ( vlc.path, "vimeo.com/%d+$" ) then
_,_,id = string.find( vlc.path, "vimeo.com/(.*)") vlc.msg.warn("matched "..vlc.path)
-- Vimeo disables HD if the user-agent contains "VLC", so we _,_,id = string.find( vlc.path, "vimeo.com/([0-9]*)")
-- set it to something inconspicuous. We do it here because
-- they seem to do some detection across requests
return { { path = "http://vimeo.com/moogaloop/load/clip:" .. id .. "/local/", name = "Vimeo playlist", options = { ":http-user-agent=Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" } } }
end
if string.match ( vlc.path, "vimeo.com/moogaloop" ) then
prefres = get_prefres() prefres = get_prefres()
ishd = false ishd = false
-- Try to find id of the video quality = "sd"
_,_,id = string.find (vlc.path, "vimeo.com/moogaloop/load/clip:(.*)/local/")
while true do while true do
-- Try to find the video's title
line = vlc.readline() line = vlc.readline()
if not line then break end if not line then break end
if string.match( line, "<caption>(.*)</caption>" ) then -- Try to find the video's title
_,_,name = string.find (line, "<caption>(.*)</caption>" ) if string.match( line, "<meta property=\"og:title\"" ) then
_,_,name = string.find (line, "content=\"(.*)\">" )
end
if string.match( line, "{config:.*\"title\":\"" ) then
_,_,name = string.find (line, "\"title\":\"([^\"]*)\"," )
end end
-- Try to find image for thumbnail -- Try to find image for thumbnail
if string.match( line, "<thumbnail>(.*)</thumbnail>" ) then if string.match( line, "<meta property=\"og:image\"" ) then
_,_,arturl = string.find (line, "<thumbnail>(.*)</thumbnail>" ) _,_,arturl = string.find (line, "content=\"(.*)\">" )
end
if string.match( line, "<meta itemprop=\"thumbnailUrl\"" ) then
_,_,arturl = string.find (line, "content=\"(.*)\">" )
end
-- Try to find duration
if string.match( line, "{config:.*\"duration\":" ) then
_,_,duration = string.find (line, "\"duration\":([0-9]*)," )
end end
-- Try to find request signature (needed to construct video url) -- Try to find request signature (needed to construct video url)
if string.match( line, "<request_signature>(.*)</request_signature>" ) then if string.match( line, "{config:.*\"signature\":" ) then
_,_,rsig = string.find (line, "<request_signature>(.*)</request_signature>" ) _,_,rsig = string.find (line, "\"signature\":\"([0-9a-f]*)\"," )
end end
-- Try to find request signature expiration time (needed to construct video url) -- Try to find request signature time (needed to construct video url)
if string.match( line, "<request_signature_expires>(.*)</request_signature_expires>" ) then if string.match( line, "{config:.*\"timestamp\":" ) then
_,_,rsigtime = string.find (line, "<request_signature_expires>(.*)</request_signature_expires>" ) _,_,tstamp = string.find (line, "\"timestamp\":([0-9]*)," )
end end
-- Try to find whether video is HD actually -- Try to find whether video is HD actually
if string.match( line, "<isHD>1</isHD>" ) then if string.match( line, "{config:.*,\"hd\":1" ) then
ishd = true ishd = true
end end
if string.match( line, "<height>%d+</height>" ) then if string.match( line, "{config:.*\"height\":" ) then
_,_,height = string.find( line, "<height>(%d+)</height>" ) _,_,height = string.find (line, "\"height\":([0-9]*)," )
end end
end end
path = "http://vimeo.com/moogaloop/play/clip:"..id.."/"..rsig.."/"..rsigtime
if ishd and ( not height or prefres < 0 or prefres >= tonumber(height) ) then if ishd and ( not height or prefres < 0 or prefres >= tonumber(height) ) then
path = path.."/?q=hd" quality = "hd"
end end
return { { path = path; name = name; arturl = arturl } } path = "http://player.vimeo.com/play_redirect?quality="..quality.."&codecs=h264&clip_id="..id.."&time="..tstamp.."&sig="..rsig.."&type=html5_desktop_local"
return { { path = path; name = name; arturl = arturl, duration = duration } }
end end
return {} return {}
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment