[vlc-commits] youtube.lua: support "sp" when passing descrambled signature

Pierre Ynard git at videolan.org
Sat Jun 15 15:58:24 CEST 2019


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sat Jun 15 15:53:21 2019 +0200| [987e020aa280b6f2a9a71b3e8ccf829fd28983f5] | committer: Pierre Ynard

youtube.lua: support "sp" when passing descrambled signature

The new signature scheme expects the descrambled signature in the "sig"
parameter of the video URL, rather than "signature" formerly. There is a
parameter indicating just this in the stream map: parse and use it.

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

 share/lua/playlist/youtube.lua | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index dbd35c56fd..41a4482873 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -107,10 +107,10 @@ function js_descramble( sig, js_url )
     end
 
     -- Look for the descrambler function's name
-    -- k.s&&f.set(k.sp,(0,window.encodeURIComponent)(DK((0,window.decodeURIComponent)(k.s))));
+    -- k.s&&f.set(k.sp,encodeURIComponent(DK(decodeURIComponent(k.s))));
     -- k.s (from stream map field "s") holds the input scrambled signature
     -- k.sp (from stream map field "sp") holds a parameter name (normally
-    -- "signature") to set with the output, descrambled signature
+    -- "signature" or "sig") to set with the output, descrambled signature
     local descrambler = js_extract( js, "%.set%([^,]-%.sp,[^;]-%((..)%(" )
     if not descrambler then
         vlc.msg.dbg( "Couldn't extract youtube video URL signature descrambling function name" )
@@ -212,7 +212,12 @@ function pick_url( url_map, fmt, js_url )
                         vlc.msg.err( "Couldn't process youtube video URL, please check for updates to this script" )
                     end
 
-                    url = url.."&signature="..vlc.strings.encode_uri_component( s )
+                    local sp = string.match( stream, "sp=([^&,]+)" )
+                    if not sp then
+                        vlc.msg.warn( "Couldn't extract signature parameters for youtube video URL, guessing" )
+                        sp = "signature"
+                    end
+                    url = url.."&"..sp.."="..vlc.strings.encode_uri_component( s )
                 end
 
                 path = url



More information about the vlc-commits mailing list