[vlc-commits] vimeo.lua: fix video quality selection
Pierre Ynard
git at videolan.org
Fri Oct 30 05:45:53 CET 2015
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Oct 30 05:44:51 2015 +0100| [02a9d0876614d0b882a5dba3cb1ea4701becda7f] | committer: Pierre Ynard
vimeo.lua: fix video quality selection
Fixes #15778
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=02a9d0876614d0b882a5dba3cb1ea4701becda7f
---
share/lua/playlist/vimeo.lua | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/share/lua/playlist/vimeo.lua b/share/lua/playlist/vimeo.lua
index 58f645a..1143d31 100644
--- a/share/lua/playlist/vimeo.lua
+++ b/share/lua/playlist/vimeo.lua
@@ -50,18 +50,27 @@ function parse()
else -- API URL
local prefres = vlc.var.inherit(nil, "preferred-resolution")
+ local bestres = nil
local line = vlc.readline() -- data is on one line only
for stream in string.gmatch( line, "{([^}]*\"profile\":[^}]*)}" ) do
local url = string.match( stream, "\"url\":\"(.-)\"" )
if url then
- path = url
- if prefres < 0 then
- break
- end
+ -- Apparently the different formats available are listed
+ -- in uncertain order of quality, so compare with what
+ -- we have so far.
local height = string.match( stream, "\"height\":(%d+)[,}]" )
- if not height or tonumber(height) <= prefres then
- break
+ height = tonumber( height )
+
+ -- Better than nothing
+ if not path or ( height and ( not bestres
+ -- Better quality within limits
+ or ( ( prefres < 0 or height <= prefres ) and height > bestres )
+ -- Lower quality more suited to limits
+ or ( prefres > -1 and bestres > prefres and height < bestres )
+ ) ) then
+ path = url
+ bestres = height
end
end
end
More information about the vlc-commits
mailing list