Commit 19d9676f authored by Pierre Ynard's avatar Pierre Ynard

dailymotion.lua: re-enable HD and convert to --preferred-resolution

parent bcd48040
......@@ -4,7 +4,7 @@
$Id$
Copyright © 2007 the VideoLAN team
Copyright © 2007-2011 the VideoLAN team
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
......@@ -21,6 +21,17 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]]
function get_prefres()
local prefres = -1
if vlc.var and vlc.var.inherit then
prefres = vlc.var.inherit(nil, "preferred-resolution")
if prefres == nil then
prefres = -1
end
end
return prefres
end
-- Probe function.
function probe()
return vlc.access == "http"
......@@ -35,13 +46,12 @@ end
-- Parse function.
function parse()
prefres = get_prefres()
while true
do
line = vlc.readline()
if not line
then
vlc.msg.err("Couldn't extract the video URL from dailymotion")
return { }
if not line then
break
end
if string.match( line, "\"sequence\",")
then
......@@ -57,24 +67,30 @@ function parse()
description = string.gsub( description, "+", " " )
end
--[[ we get a list of different streams available, at various codecs
and resolutions:
Ideally, VLC would propose the different streams available,
codecs and resolutions (the resolutions are part of the URL)
For now we just built a list of preferred codecs : lowest value
means highest priority
]]--
-- FIXME: the hd/hq versions (in mp4) cause a lot of seeks,
-- for now we only get the sd (in flv) URL
for _,param in ipairs({ "hd1080URL", "hd720URL", "hqURL", "sdURL" }) do
path = string.match( line, "\""..param.."\":\"([^\"]*)\"" )
if path then
if prefres < 0 then
break
end
height = string.match( path, "/cdn/%w+%-%d+x(%d+)/video/" )
if not height then
height = string.match( param, "(%d+)" )
end
if not height or tonumber(height) <= prefres then
break
end
end
end
-- if not path then path = find( line, "\"hqURL\":\"([^\"]*)\"") end
-- if not path then path = find( line, "\"hdURL\":\"([^\"]*)\"") end
if not path then path = find( line, "\"sdURL\":\"([^\"]*)\"") end
if not path then
break
end
return { { path = path; name = name; description = description; url = vlc.path; arturl = arturl } }
end
end
vlc.msg.err("Couldn't extract the video URL from dailymotion")
return { }
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