Skip to content

Commit

Permalink
yt: sync descrambler parse with vlc - https://code.videolan.org/video…
Browse files Browse the repository at this point in the history
  • Loading branch information
satbaby committed Feb 6, 2022
1 parent 45ea08b commit 1efdfce
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
34 changes: 31 additions & 3 deletions plugins/rss/rss_addon/yt_video_url.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,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",' )--org
local descrambler = js_extract( js, 'set%("n",.%),...%.length||(...)' )--my
-- 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
print( "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
print( "Couldn't extract YouTube video throttling parameter descrambling function name" )
return nil
Expand Down
35 changes: 31 additions & 4 deletions plugins/webtv/yt_live.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,38 @@ function n_descramble( nparam, js )
if not js then
return nil
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",' )--org
local descrambler = js_extract( js, 'set%("n",.%),...%.length||(...)' )--my
-- 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
print( "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
print( "Couldn't extract YouTube video throttling parameter descrambling function name" )
return nil
Expand Down

0 comments on commit 1efdfce

Please sign in to comment.