vlc | branch: master | Pierre Ynard <[email protected]> | Sun Jan 27 05:12:25 2019 +0100| [2e04176d26a00c2b0a6bdf57175f72856d7942b7] | committer: Pierre Ynard
vimeo.lua: switch player redirection to hard-coded API URL Access player config API directly rather than player page. Stop parsing web page contents for the player URL, it's simpler to extract and insert the video ID from the calling URL; the player URL is half hard-coded in the rest of the script anyway. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e04176d26a00c2b0a6bdf57175f72856d7942b7 --- share/lua/playlist/vimeo.lua | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/share/lua/playlist/vimeo.lua b/share/lua/playlist/vimeo.lua index 6cc332e2ab..9c08a28b43 100644 --- a/share/lua/playlist/vimeo.lua +++ b/share/lua/playlist/vimeo.lua @@ -31,27 +31,7 @@ end -- Parse function. function parse() - if not string.match( vlc.path, "player%.vimeo%.com" ) then -- Web page URL - while true do - local line = vlc.readline() - if not line then break end - - -- Get the appropriate ubiquitous meta tag - -- <meta name="twitter:player" content="https://player.vimeo.com/video/123456789"> - local meta = string.match( line, "(<meta[^>]- name=\"twitter:player\"[^>]->)" ) - if meta then - local path = string.match( meta, " content=\"(.-)\"" ) - if path then - path = vlc.strings.resolve_xml_special_chars( path ) - return { { path = path } } - end - end - end - - vlc.msg.err( "Couldn't extract vimeo video URL, please check for updates to this script" ) - return { } - - else -- API URL + if string.match( vlc.path, "^player%.vimeo%.com/" ) then -- The /config API will return the data on a single line. -- Otherwise, search the web page for the config. local config = vlc.readline() @@ -100,5 +80,12 @@ function parse() local duration = string.match( config, "\"duration\":(%d+)[,}]" ) return { { path = path; name = name; artist = artist; arturl = arturl; duration = duration } } + + else -- Video web page + local path = string.gsub( vlc.path, "^vimeo%.com/channels/.-/(%d+)", "/%1" ) + local video_id = string.match( path, "/(%d+)" ) + + local api = vlc.access.."://player.vimeo.com/video/"..video_id.."/config" + return { { path = api } } end end _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
