[vlc-commits] vimeo.lua: fix video quality selection

Pierre Ynard git at videolan.org
Sat Oct 31 17:29:38 CET 2015


vlc/vlc-2.2 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Fri Oct 30 05:44:51 2015 +0100| [a09ae71be5904ed77ab6d740ae153c8b6b45c4f0] | committer: Jean-Baptiste Kempf

vimeo.lua: fix video quality selection

Fixes #15778

(cherry picked from commit 02a9d0876614d0b882a5dba3cb1ea4701becda7f)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=a09ae71be5904ed77ab6d740ae153c8b6b45c4f0
---

 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 9bd41b7..e8501f6 100644
--- a/share/lua/playlist/vimeo.lua
+++ b/share/lua/playlist/vimeo.lua
@@ -61,18 +61,27 @@ function parse()
     else -- API URL
 
         local prefres = get_prefres()
+        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