[vlc-commits] dailymotion.lua: re-enable HD and convert to --preferred-resolution
Pierre Ynard
git at videolan.org
Mon Sep 19 02:33:27 CEST 2011
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Mon Sep 19 02:32:32 2011 +0200| [19d9676f538f8f2f7a29f1255e92a9849c2c397b] | committer: Pierre Ynard
dailymotion.lua: re-enable HD and convert to --preferred-resolution
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19d9676f538f8f2f7a29f1255e92a9849c2c397b
---
share/lua/playlist/dailymotion.lua | 56 +++++++++++++++++++++++-------------
1 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/share/lua/playlist/dailymotion.lua b/share/lua/playlist/dailymotion.lua
index 4af70f7..b6b43ed 100644
--- a/share/lua/playlist/dailymotion.lua
+++ b/share/lua/playlist/dailymotion.lua
@@ -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
More information about the vlc-commits
mailing list