youtube.lua: split stream URL parsing into separate function

This commit is contained in:
Pierre Ynard 2023-02-11 08:45:15 +01:00 committed by Jean-Baptiste Kempf
parent 94d5e1aa65
commit b88da3715b
1 changed files with 6 additions and 0 deletions

View File

@ -720,7 +720,12 @@ function pick_stream_url( muxed, adaptive, js_url, fmt )
if not pick then
return nil
end
return assemble_stream_url( pick, js )
end
-- Parse, descramble and assemble elements of video stream URL
function assemble_stream_url( pick, js )
-- 1/ URL signature
-- Either the "url" or the "signatureCipher" parameter is present,
-- depending on whether the URL signature is scrambled.
local url
@ -739,6 +744,7 @@ function pick_stream_url( muxed, adaptive, js_url, fmt )
return nil
end
-- 2/ Data transfer throttling
-- The "n" parameter is scrambled too, and needs to be descrambled
-- and replaced in place, otherwise the data transfer gets throttled
-- down to between 40 and 80 kB/s, below real-time playability level.