Skip to content

Commit

Permalink
vimeo.lua: fix video quality selection
Browse files Browse the repository at this point in the history
Fixes #15778
  • Loading branch information
linkfanel committed Oct 30, 2015
1 parent 610ecb9 commit 02a9d08
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions share/lua/playlist/vimeo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 02a9d08

Please sign in to comment.