mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-08-27 17:52:02 +02:00
[downloader/ffmpeg] Specify headers for each URL (#3553)
Closes #2696 Authored by: elyse0
This commit is contained in:
parent
7ab56be2c7
commit
00828e2c93
@ -382,13 +382,15 @@ def _call_downloader(self, tmpfilename, info_dict):
|
|||||||
# if end_time:
|
# if end_time:
|
||||||
# args += ['-t', compat_str(end_time - start_time)]
|
# args += ['-t', compat_str(end_time - start_time)]
|
||||||
|
|
||||||
if info_dict.get('http_headers') is not None and re.match(r'^https?://', urls[0]):
|
http_headers = None
|
||||||
# Trailing \r\n after each HTTP header is important to prevent warning from ffmpeg/avconv:
|
if info_dict.get('http_headers'):
|
||||||
# [http @ 00000000003d2fa0] No trailing CRLF found in HTTP header.
|
youtubedl_headers = handle_youtubedl_headers(info_dict['http_headers'])
|
||||||
headers = handle_youtubedl_headers(info_dict['http_headers'])
|
http_headers = [
|
||||||
args += [
|
# Trailing \r\n after each HTTP header is important to prevent warning from ffmpeg/avconv:
|
||||||
|
# [http @ 00000000003d2fa0] No trailing CRLF found in HTTP header.
|
||||||
'-headers',
|
'-headers',
|
||||||
''.join(f'{key}: {val}\r\n' for key, val in headers.items())]
|
''.join(f'{key}: {val}\r\n' for key, val in youtubedl_headers.items())
|
||||||
|
]
|
||||||
|
|
||||||
env = None
|
env = None
|
||||||
proxy = self.params.get('proxy')
|
proxy = self.params.get('proxy')
|
||||||
@ -441,6 +443,11 @@ def _call_downloader(self, tmpfilename, info_dict):
|
|||||||
args += ['-rtmp_conn', conn]
|
args += ['-rtmp_conn', conn]
|
||||||
|
|
||||||
for i, url in enumerate(urls):
|
for i, url in enumerate(urls):
|
||||||
|
# We need to specify headers for each http input stream
|
||||||
|
# otherwise, it will only be applied to the first.
|
||||||
|
# https://github.com/yt-dlp/yt-dlp/issues/2696
|
||||||
|
if http_headers is not None and re.match(r'^https?://', url):
|
||||||
|
args += http_headers
|
||||||
args += self._configuration_args((f'_i{i + 1}', '_i')) + ['-i', url]
|
args += self._configuration_args((f'_i{i + 1}', '_i')) + ['-i', url]
|
||||||
|
|
||||||
args += ['-c', 'copy']
|
args += ['-c', 'copy']
|
||||||
|
Loading…
Reference in New Issue
Block a user