Commit 51047a67 authored by Pierre Ynard's avatar Pierre Ynard

youtube.lua: parse signature parameter

It was in fact still there, but as a separate parameter. We keep the
alternate API as a fallback for the next time things break, maybe.

Ref #7471
(cherry picked from commit 3a4021cfde854da79675fa67df47fc4f463f264b)
Signed-off-by: default avatarPierre Ynard <linkfanel@yahoo.fr>
parent b228a86f
...@@ -70,22 +70,22 @@ end ...@@ -70,22 +70,22 @@ end
-- Parse and pick our video URL -- Parse and pick our video URL
function pick_url( url_map, fmt ) function pick_url( url_map, fmt )
local path = nil local path = nil
-- Handle both orderings, as unfortunately both may appear for stream in string.gmatch( url_map, "[^,]+" ) do
if string.match( url_map, "^url" ) then
for url,itag in string.gmatch( url_map, "url=([^&,]+)[^,]*&itag=(%d+)" ) do
-- Apparently formats are listed in quality order, -- Apparently formats are listed in quality order,
-- so we can afford to simply take the first one -- so we can afford to simply take the first one
if not fmt or tonumber( itag ) == tonumber( fmt ) then local itag = string.match( stream, "itag=(%d+)" )
if not fmt or not itag or tonumber( itag ) == tonumber( fmt ) then
local url = string.match( stream, "url=([^&,]+)" )
if url then
url = vlc.strings.decode_uri( url ) url = vlc.strings.decode_uri( url )
path = url
break local sig = string.match( stream, "sig=([^&,]+)" )
end local signature = ""
if sig then
signature = "&signature="..sig
end end
else
for itag,url in string.gmatch( url_map, "itag=(%d+)&[^,]*url=([^&,]+)" ) do path = url..signature
if not fmt or tonumber( itag ) == tonumber( fmt ) then
url = vlc.strings.decode_uri( url )
path = url
break break
end end
end end
...@@ -120,9 +120,6 @@ function parse() ...@@ -120,9 +120,6 @@ function parse()
-- fmt is the format of the video -- fmt is the format of the video
-- (cf. http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs) -- (cf. http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs)
fmt = get_url_param( vlc.path, "fmt" ) fmt = get_url_param( vlc.path, "fmt" )
-- URLs in the web page are no good since
-- they miss the "signature" parameter :/
--[[
while true do while true do
-- Try to find the video's title -- Try to find the video's title
line = vlc.readline() line = vlc.readline()
...@@ -166,8 +163,8 @@ function parse() ...@@ -166,8 +163,8 @@ function parse()
-- tag; but we don't need it now -- tag; but we don't need it now
end end
end end
--]]
if not path then
local video_id = get_url_param( vlc.path, "v" ) local video_id = get_url_param( vlc.path, "v" )
if video_id then if video_id then
if fmt then if fmt then
...@@ -179,6 +176,8 @@ function parse() ...@@ -179,6 +176,8 @@ function parse()
-- music videos with errors about copyrighted content being -- music videos with errors about copyrighted content being
-- "restricted from playback on certain sites" -- "restricted from playback on certain sites"
path = "http://www.youtube.com/get_video_info?video_id="..video_id..format.."&el=detailpage" path = "http://www.youtube.com/get_video_info?video_id="..video_id..format.."&el=detailpage"
vlc.msg.warn( "Couldn't extract video URL, falling back to alternate youtube API" )
end
end end
if not path then if not path then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment