]> git.sesse.net Git - vlc/commitdiff
youtube.lua: handle inlined function in descrambling javascript
authorPierre Ynard <linkfanel@yahoo.fr>
Sun, 22 Sep 2013 02:29:47 +0000 (04:29 +0200)
committerPierre Ynard <linkfanel@yahoo.fr>
Sun, 22 Sep 2013 02:29:47 +0000 (04:29 +0200)
share/lua/playlist/youtube.lua

index 5778adb8d49863466a0007baf0dfb04c66c62ed1..30da2f81f935a78b45dd00f260a4c0d0d01bd6da 100644 (file)
@@ -128,6 +128,12 @@ function js_descramble( sig, js_url )
         -- characters:
         -- function jj(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c;return a}
         local idx = string.match( rule, "=..%([^,]+,(%d+)%)" )
+        -- This swapping function may also appear inlined:
+        -- var b=a[0];a[0]=a[59%a.length];a[59]=b;
+        -- In that case we only catch one of the three rules.
+        if not idx then
+            idx = string.match( rule, ".%[(%d+)%]=." )
+        end
         if idx then
             idx = tonumber( idx )
             if not idx then idx = 0 end