mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-03-09 12:50:23 -05:00
feat: first pass at handling redirects in process_ie_result()
This commit is contained in:
parent
0b6b7742c2
commit
6cd95babef
1 changed files with 12 additions and 0 deletions
|
@ -1822,6 +1822,18 @@ def process_ie_result(self, ie_result, download=True, extra_info=None):
|
|||
result_type = ie_result.get('_type', 'video')
|
||||
|
||||
if result_type in ('url', 'url_transparent'):
|
||||
if 'redirect_count' in extra_info:
|
||||
extra_info['redirect_count'] = 1 + extra_info.get('redirect_count', 0)
|
||||
else:
|
||||
extra_info['redirect_count'] = 0
|
||||
|
||||
# TODO: make command line arg with large or infinite default
|
||||
if extra_info['redirect_count'] >= 5:
|
||||
raise ExtractorError(
|
||||
f"Too many redirects for URL: {ie_result['url']}",
|
||||
expected=True,
|
||||
)
|
||||
|
||||
ie_result['url'] = sanitize_url(
|
||||
ie_result['url'], scheme='http' if self.params.get('prefer_insecure') else 'https')
|
||||
if ie_result.get('original_url') and not extra_info.get('original_url'):
|
||||
|
|
Loading…
Reference in a new issue