ytdl_hook: always set HTTP headers

In some cases HTTP headers were not set, leading to some sites not
working despite being supported by yt-dlp/youtube-dl.
This commit is contained in:
Christoph Heinrich 2022-07-15 02:12:58 +02:00 committed by Dudemanguy
parent 70fa9502f3
commit 431473310f
1 changed files with 6 additions and 2 deletions

View File

@ -525,6 +525,10 @@ local function add_single_video(json)
local max_bitrate = 0
local requested_formats = json["requested_formats"]
local all_formats = json["formats"]
local has_requested_formats = requested_formats and #requested_formats > 0
local http_headers = has_requested_formats
and requested_formats[1].http_headers
or json.http_headers
if o.use_manifests and valid_manifest(json) then
-- prefer manifest_url if present
@ -554,7 +558,6 @@ local function add_single_video(json)
if streamurl == "" then
-- possibly DASH/split tracks
local res = nil
local has_requested_formats = requested_formats and #requested_formats > 0
-- Not having requested_formats usually hints to HLS master playlist
-- usage, which we don't want to split off, at least not yet.
@ -591,7 +594,6 @@ local function add_single_video(json)
end
-- normal video or single track
streamurl = edl_track or json.url
set_http_headers(json.http_headers)
end
if streamurl == "" then
@ -599,6 +601,8 @@ local function add_single_video(json)
return
end
set_http_headers(http_headers)
msg.verbose("format selection: " .. format_info)
msg.debug("streamurl: " .. streamurl)