mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-14 04:05:16 +00:00
chore: replace hard-coded limit with command line option
This commit is contained in:
@@ -1822,17 +1822,17 @@ class YoutubeDL:
|
||||
result_type = ie_result.get('_type', 'video')
|
||||
|
||||
if result_type in ('url', 'url_transparent'):
|
||||
if 'extraction_depth' in extra_info:
|
||||
extra_info['extraction_depth'] = 1 + extra_info.get('extraction_depth', 0)
|
||||
else:
|
||||
extra_info['extraction_depth'] = 0
|
||||
if self.params.get('max_extraction_depth', -1) > 0:
|
||||
if 'extraction_depth' in extra_info:
|
||||
extra_info['extraction_depth'] = 1 + extra_info.get('extraction_depth', 0)
|
||||
else:
|
||||
extra_info['extraction_depth'] = 0
|
||||
|
||||
# TODO: make command line arg with large or infinite default
|
||||
if extra_info['extraction_depth'] >= 20:
|
||||
raise ExtractorError(
|
||||
f"Too many hops for URL: {ie_result['url']}",
|
||||
expected=True,
|
||||
)
|
||||
if extra_info['extraction_depth'] >= self.params.get('max_extraction_depth'):
|
||||
raise ExtractorError(
|
||||
f"Reached maximum extraction depth 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')
|
||||
|
||||
Reference in New Issue
Block a user