Commit 02a9d087 authored by Pierre Ynard's avatar Pierre Ynard

vimeo.lua: fix video quality selection

Fixes #15778
parent 610ecb90
...@@ -50,18 +50,27 @@ function parse() ...@@ -50,18 +50,27 @@ function parse()
else -- API URL else -- API URL
local prefres = vlc.var.inherit(nil, "preferred-resolution") local prefres = vlc.var.inherit(nil, "preferred-resolution")
local bestres = nil
local line = vlc.readline() -- data is on one line only local line = vlc.readline() -- data is on one line only
for stream in string.gmatch( line, "{([^}]*\"profile\":[^}]*)}" ) do for stream in string.gmatch( line, "{([^}]*\"profile\":[^}]*)}" ) do
local url = string.match( stream, "\"url\":\"(.-)\"" ) local url = string.match( stream, "\"url\":\"(.-)\"" )
if url then if url then
path = url -- Apparently the different formats available are listed
if prefres < 0 then -- in uncertain order of quality, so compare with what
break -- we have so far.
end
local height = string.match( stream, "\"height\":(%d+)[,}]" ) local height = string.match( stream, "\"height\":(%d+)[,}]" )
if not height or tonumber(height) <= prefres then height = tonumber( height )
break
-- 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 end
end 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