[vlc-commits] youtube.lua: look for javascript descrambling URL on any line

Pierre Ynard git at videolan.org
Thu Nov 12 07:36:49 CET 2020


vlc/vlc-3.0 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Nov 12 06:04:57 2020 +0100| [8611b6b5bd2a32a7f81f274b00abae848b0207da] | committer: Pierre Ynard

youtube.lua: look for javascript descrambling URL on any line

This URL is forwarded to the fallback API and the whole point of that is
in case the main stream configuration line can't be found and parsed,
so don't look for it only on that line. The URL can indeed be found in
several other places on the page.

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

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

 share/lua/playlist/youtube.lua | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index 4ee599c7b9..a94e6f881a 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -327,6 +327,7 @@ function parse()
         or string.match( vlc.path, "/live$" )
         or string.match( vlc.path, "/live%?" )
     then -- This is the HTML page's URL
+        local js_url
         -- fmt is the format of the video
         -- (cf. http://en.wikipedia.org/wiki/YouTube#Quality_and_formats)
         fmt = get_url_param( vlc.path, "fmt" )
@@ -409,11 +410,10 @@ function parse()
                 end
             end
 
-            -- JSON parameters, also formerly known as "swfConfig",
-            -- "SWF_ARGS", "swfArgs", "PLAYER_CONFIG", "playerConfig" ...
-            if string.match( line, "ytplayer%.config" ) then
-
-                local js_url = string.match( line, '"jsUrl":"(.-)"' )
+            -- We need this when parsing the main stream configuration;
+            -- it can indeed be found on that same line (among others).
+            if not js_url then
+                js_url = string.match( line, '"jsUrl":"(.-)"' )
                     or string.match( line, "\"js\": *\"(.-)\"" )
                 if js_url then
                     js_url = string.gsub( js_url, "\\/", "/" )
@@ -424,6 +424,11 @@ function parse()
                     end
                     js_url = string.gsub( js_url, "^//", vlc.access.."://" )
                 end
+            end
+
+            -- JSON parameters, also formerly known as "swfConfig",
+            -- "SWF_ARGS", "swfArgs", "PLAYER_CONFIG", "playerConfig" ...
+            if string.match( line, "ytplayer%.config" ) then
 
                 -- Classic parameters - out of use since early 2020
                 if not fmt then



More information about the vlc-commits mailing list