mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 07:06:52 +01:00
parent
ca6d59d2c1
commit
415f8d51a8
@ -1038,6 +1038,7 @@ def validate_outtmpl(cls, outtmpl):
|
||||
def _copy_infodict(info_dict):
|
||||
info_dict = dict(info_dict)
|
||||
info_dict.pop('__postprocessors', None)
|
||||
info_dict.pop('__pending_error', None)
|
||||
return info_dict
|
||||
|
||||
def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False):
|
||||
@ -1529,6 +1530,7 @@ def process_ie_result(self, ie_result, download=True, extra_info=None):
|
||||
self.add_extra_info(info_copy, extra_info)
|
||||
info_copy, _ = self.pre_process(info_copy)
|
||||
self.__forced_printings(info_copy, self.prepare_filename(info_copy), incomplete=True)
|
||||
self._raise_pending_errors(info_copy)
|
||||
if self.params.get('force_write_download_archive', False):
|
||||
self.record_download_archive(info_copy)
|
||||
return ie_result
|
||||
@ -1536,6 +1538,7 @@ def process_ie_result(self, ie_result, download=True, extra_info=None):
|
||||
if result_type == 'video':
|
||||
self.add_extra_info(ie_result, extra_info)
|
||||
ie_result = self.process_video_result(ie_result, download=download)
|
||||
self._raise_pending_errors(ie_result)
|
||||
additional_urls = (ie_result or {}).get('additional_urls')
|
||||
if additional_urls:
|
||||
# TODO: Improve MetadataParserPP to allow setting a list
|
||||
@ -2383,6 +2386,11 @@ def _fill_common_fields(self, info_dict, is_video=True):
|
||||
if info_dict.get('%s_number' % field) is not None and not info_dict.get(field):
|
||||
info_dict[field] = '%s %d' % (field.capitalize(), info_dict['%s_number' % field])
|
||||
|
||||
def _raise_pending_errors(self, info):
|
||||
err = info.pop('__pending_error', None)
|
||||
if err:
|
||||
self.report_error(err, tb=False)
|
||||
|
||||
def process_video_result(self, info_dict, download=True):
|
||||
assert info_dict.get('_type', 'video') == 'video'
|
||||
self._num_videos += 1
|
||||
@ -2643,6 +2651,7 @@ def is_wellformed(f):
|
||||
self.process_info(new_info)
|
||||
except MaxDownloadsReached:
|
||||
max_downloads_reached = True
|
||||
self._raise_pending_errors(new_info)
|
||||
# Remove copied info
|
||||
for key, val in tuple(new_info.items()):
|
||||
if info_dict.get(key) == val:
|
||||
@ -2987,12 +2996,8 @@ def replace_info_dict(new_info):
|
||||
info_dict.clear()
|
||||
info_dict.update(new_info)
|
||||
|
||||
try:
|
||||
new_info, files_to_move = self.pre_process(info_dict, 'before_dl', files_to_move)
|
||||
replace_info_dict(new_info)
|
||||
except PostProcessingError as err:
|
||||
self.report_error('Preprocessing: %s' % str(err))
|
||||
return
|
||||
new_info, files_to_move = self.pre_process(info_dict, 'before_dl', files_to_move)
|
||||
replace_info_dict(new_info)
|
||||
|
||||
if self.params.get('skip_download'):
|
||||
info_dict['filepath'] = temp_filename
|
||||
@ -3152,6 +3157,7 @@ def correct_ext(filename, ext=new_ext):
|
||||
self.report_error(f'content too short (expected {err.expected} bytes and served {err.downloaded})')
|
||||
return
|
||||
|
||||
self._raise_pending_errors(info_dict)
|
||||
if success and full_filename != '-':
|
||||
|
||||
def fixup():
|
||||
@ -3369,7 +3375,12 @@ def run_all_pps(self, key, info, *, additional_pps=None):
|
||||
def pre_process(self, ie_info, key='pre_process', files_to_move=None):
|
||||
info = dict(ie_info)
|
||||
info['__files_to_move'] = files_to_move or {}
|
||||
info = self.run_all_pps(key, info)
|
||||
try:
|
||||
info = self.run_all_pps(key, info)
|
||||
except PostProcessingError as err:
|
||||
msg = f'Preprocessing: {err}'
|
||||
info.setdefault('__pending_error', msg)
|
||||
self.report_error(msg, is_error=False)
|
||||
return info, info.pop('__files_to_move', None)
|
||||
|
||||
def post_process(self, filename, info, files_to_move=None):
|
||||
|
Loading…
Reference in New Issue
Block a user