[vlc-commits] vimeo.lua: support HTML player page

Pierre Ynard git at videolan.org
Sun Jan 27 05:29:30 CET 2019


vlc/vlc-3.0 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Jan 27 05:09:11 2019 +0100| [c148adf46fdd1c87a00ba13913e1e15139d3f9dc] | committer: Pierre Ynard

vimeo.lua: support HTML player page

The config API is at a slightly different URL, but both are supported
now.

(cherry picked from commit cff0b2e9b7416910931baa0feeb17a99d44ed019)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>

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

 share/lua/playlist/vimeo.lua | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/share/lua/playlist/vimeo.lua b/share/lua/playlist/vimeo.lua
index fafc24852e..6cc332e2ab 100644
--- a/share/lua/playlist/vimeo.lua
+++ b/share/lua/playlist/vimeo.lua
@@ -52,12 +52,22 @@ function parse()
         return { }
 
     else -- API URL
+        -- The /config API will return the data on a single line.
+        -- Otherwise, search the web page for the config.
+        local config = vlc.readline()
+        while true do
+            local line = vlc.readline()
+            if not line then break end
+            if string.match( line, "var config = {" ) then
+                config = line
+                break
+            end
+        end
 
         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
+        for stream in string.gmatch( config, "{([^}]*\"profile\":[^}]*)}" ) do
             local url = string.match( stream, "\"url\":\"(.-)\"" )
             if url then
                 -- Apparently the different formats available are listed
@@ -84,10 +94,10 @@ function parse()
             return { }
         end
 
-        local name = string.match( line, "\"title\":\"(.-)\"" )
-        local artist = string.match( line, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
-        local arturl = string.match( line, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
-        local duration = string.match( line, "\"duration\":(%d+)[,}]" )
+        local name = string.match( config, "\"title\":\"(.-)\"" )
+        local artist = string.match( config, "\"owner\":{[^}]-\"name\":\"(.-)\"" )
+        local arturl = string.match( config, "\"thumbs\":{\"[^\"]+\":\"(.-)\"" )
+        local duration = string.match( config, "\"duration\":(%d+)[,}]" )
 
         return { { path = path; name = name; artist = artist; arturl = arturl; duration = duration } }
     end



More information about the vlc-commits mailing list