1
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-03-09 12:50:23 -05:00

Reverted unrelated changes

This commit is contained in:
Kieran Eglin 2024-04-26 13:55:07 -07:00
parent 0a3c5aceb5
commit a1ff1d4272
No known key found for this signature in database
GPG key ID: 193984967FCF432D

View file

@ -1982,9 +1982,8 @@ def __process_playlist(self, ie_result, download):
'playlist', ie_result, self.prepare_filename(ie_copy, 'pl_infojson')) 'playlist', ie_result, self.prepare_filename(ie_copy, 'pl_infojson'))
if _infojson_written is None: if _infojson_written is None:
return return
if self._write_description('playlist', ie_result,
description_file = self._write_description('playlist', ie_result, self.prepare_filename(ie_copy, 'pl_description')) self.prepare_filename(ie_copy, 'pl_description')) is None:
if description_file is None:
return return
# TODO: This should be passed to ThumbnailsConvertor if necessary # TODO: This should be passed to ThumbnailsConvertor if necessary
self._write_thumbnails('playlist', ie_result, self.prepare_filename(ie_copy, 'pl_thumbnail')) self._write_thumbnails('playlist', ie_result, self.prepare_filename(ie_copy, 'pl_thumbnail'))
@ -3229,8 +3228,8 @@ def check_max_downloads():
if not self._ensure_dir_exists(encodeFilename(temp_filename)): if not self._ensure_dir_exists(encodeFilename(temp_filename)):
return return
description_file = self._write_description('video', info_dict, self.prepare_filename(info_dict, 'description')) if self._write_description('video', info_dict,
if description_file is None: self.prepare_filename(info_dict, 'description')) is None:
return return
sub_files = self._write_subtitles(info_dict, temp_filename) sub_files = self._write_subtitles(info_dict, temp_filename)
@ -4233,27 +4232,27 @@ def _write_info_json(self, label, ie_result, infofn, overwrite=None):
self.report_error(f'Cannot write {label} metadata to JSON file {infofn}') self.report_error(f'Cannot write {label} metadata to JSON file {infofn}')
return None return None
def _write_description(self, label, info_dict, filename): def _write_description(self, label, ie_result, descfn):
''' Write description and returns True = written, False = skip, None = error ''' ''' Write description and returns True = written, False = skip, None = error '''
if not self.params.get('writedescription'): if not self.params.get('writedescription'):
return False return False
elif not filename: elif not descfn:
self.write_debug(f'Skipping writing {label} description') self.write_debug(f'Skipping writing {label} description')
return False return False
elif not self._ensure_dir_exists(filename): elif not self._ensure_dir_exists(descfn):
return None return None
elif not self.params.get('overwrites', True) and os.path.exists(filename): elif not self.params.get('overwrites', True) and os.path.exists(descfn):
self.to_screen(f'[info] {label.title()} description is already present') self.to_screen(f'[info] {label.title()} description is already present')
elif info_dict.get('description') is None: elif ie_result.get('description') is None:
self.to_screen(f'[info] There\'s no {label} description to write') self.to_screen(f'[info] There\'s no {label} description to write')
return False return False
else: else:
try: try:
self.to_screen(f'[info] Writing {label} description to: {filename}') self.to_screen(f'[info] Writing {label} description to: {descfn}')
with open(filename, 'w', encoding='utf-8') as descfile: with open(encodeFilename(descfn), 'w', encoding='utf-8') as descfile:
descfile.write(info_dict['description']) descfile.write(ie_result['description'])
except OSError: except OSError:
self.report_error(f'Cannot write {label} description file {filename}') self.report_error(f'Cannot write {label} description file {descfn}')
return None return None
return True return True