[vlc-commits] [Git][videolan/vlc][master] 2 commits: youtube.lua: update "n" descrambling function name parsing

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sun Feb 6 08:39:25 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
3df28fc5 by Pierre Ynard at 2022-02-06T08:24:28+00:00
youtube.lua: update "n" descrambling function name parsing

The descrambling function is now called through an intermediate array
variable. This change has also added two extra ways to recover the
function name. Add support to parse and resolve any of them.

Fixes #26574

- - - - -
3c9c32ab by Pierre Ynard at 2022-02-06T08:24:28+00:00
vocaroo.lua: pass HTTP referrer to media URL request

Since last month, requests without a valid referrer get rejected with an
HTTP 403 error.

We might want to consider that the lua script API should track and pass
such referrers by itself.

- - - - -


2 changed files:

- share/lua/playlist/vocaroo.lua
- share/lua/playlist/youtube.lua


Changes:

=====================================
share/lua/playlist/vocaroo.lua
=====================================
@@ -1,7 +1,7 @@
 --[[
  $Id$
 
- Copyright © 2016, 2019-2020 the VideoLAN team
+ Copyright © 2016, 2019-2020, 2022 the VideoLAN team
 
  Authors: Pierre Ynard
 
@@ -39,6 +39,6 @@ function parse()
         or "//media.vocaroo.com/mp3/"
 
     local path = vlc.access..":"..cdn..id
-    return { { path = path } }
+    return { { path = path; options = { ":http-referrer="..vlc.access.."://"..vlc.path } } }
 end
 


=====================================
share/lua/playlist/youtube.lua
=====================================
@@ -1,7 +1,7 @@
 --[[
  $Id$
 
- Copyright © 2007-2021 the VideoLAN team
+ Copyright © 2007-2022 the VideoLAN team
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -119,8 +119,37 @@ function n_descramble( nparam, js )
     end
 
     -- Look for the descrambler function's name
-    -- a.D&&(b=a.get("n"))&&(b=lha(b),a.set("n",b))}};
-    local descrambler = js_extract( js, '[=%(,&|](...?)%(.%),.%.set%("n",' )
+    -- a.C&&(b=a.get("n"))&&(b=Bpa[0](b),a.set("n",b),Bpa.length||iha(""))}};
+    -- var Bpa=[iha];
+    local callsite = js_extract( js, '[^;]*%.set%("n",[^};]*' )
+    if not callsite then
+        vlc.msg.dbg( "Couldn't extract YouTube video throttling parameter descrambling function name" )
+        return nil
+    end
+
+    -- Try direct function name from following clause
+    local descrambler = string.match( callsite, '%.set%("n",.%),...?%.length||(...?)%(' )
+    local itm = nil
+    if not descrambler then
+        -- Try from main call site
+        descrambler = string.match( callsite, '[=%(,&|]([a-zA-Z0-9_$%[%]]+)%(.%),.%.set%("n",' )
+        if descrambler then
+            -- Check if this is only an intermediate variable
+            itm = string.match( descrambler, '^([^%[%]]+)%[' )
+            if itm then
+                descrambler = nil
+            end
+        else
+            -- Last chance: intermediate variable in following clause
+            itm = string.match( callsite, '%.set%("n",.%),(...?)%.length' )
+        end
+    end
+
+    if not descrambler and itm then
+        -- Resolve intermediate variable
+        descrambler = js_extract( js, 'var '..itm..'=%[(...?)[%],]' )
+    end
+
     if not descrambler then
         vlc.msg.dbg( "Couldn't extract YouTube video throttling parameter descrambling function name" )
         return nil



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6550059ef2cd9751f39661b1b60b83c27c58696b...3c9c32ab3bd0258aa55bd353609c96846ce21373

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6550059ef2cd9751f39661b1b60b83c27c58696b...3c9c32ab3bd0258aa55bd353609c96846ce21373
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list