[vlc-commits] youtube.lua: forward javascript descrambling URL to alternate API
Pierre Ynard
git at videolan.org
Thu Nov 12 07:28:21 CET 2020
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Thu Nov 12 05:58:28 2020 +0100| [2d0f63a61b038d5d379acb85844450b0a61c1047] | committer: Pierre Ynard
youtube.lua: forward javascript descrambling URL to alternate API
This renders the fallback to the alternate video info API - which
doesn't provide the javascript URL itself - functional with many more
videos, and makes the script as a whole more resilient to future
failures.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d0f63a61b038d5d379acb85844450b0a61c1047
---
share/lua/playlist/youtube.lua | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index 39b824f90a..4ee599c7b9 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -480,6 +480,16 @@ function parse()
-- of "embedded" and "detailpage" have historically been
-- wrong and failed for various restricted videos.
path = vlc.access.."://www.youtube.com/get_video_info?video_id="..video_id..copy_url_param( vlc.path, "fmt" )
+
+ -- The YouTube API output doesn't provide the URL to the
+ -- javascript code necessary to descramble URL signatures,
+ -- without which functionality can be seriously limited.
+ -- #18801 prevents us from using a subrequest to the API,
+ -- so we forward the URL this way.
+ if js_url then
+ path = path.."&jsurl="..vlc.strings.encode_uri_component( js_url )
+ end
+
vlc.msg.warn( "Couldn't extract video URL, falling back to alternate youtube API" )
end
end
@@ -502,6 +512,11 @@ function parse()
return { }
end
+ local js_url = get_url_param( vlc.path, "jsurl" )
+ if js_url then
+ js_url= vlc.strings.decode_uri( js_url )
+ end
+
-- Classic parameters - out of use since early 2020
local fmt = get_url_param( vlc.path, "fmt" )
if not fmt then
@@ -516,7 +531,7 @@ function parse()
if url_map then
vlc.msg.dbg( "Found classic parameters for youtube video stream, parsing..." )
url_map = vlc.strings.decode_uri( url_map )
- path = pick_url( url_map, fmt )
+ path = pick_url( url_map, fmt, js_url )
end
-- New-style parameters
@@ -527,7 +542,7 @@ function parse()
stream_map = vlc.strings.decode_uri( stream_map )
-- FIXME: do this properly (see #24958)
stream_map = string.gsub( stream_map, "\\u0026", "&" )
- path = pick_stream( stream_map )
+ path = pick_stream( stream_map, js_url )
end
end
More information about the vlc-commits
mailing list