Fix `--no-overwrite` for playlist infojson

Fixes: https://github.com/yt-dlp/yt-dlp/issues/1467#issuecomment-1079922971
pull/3234/head
pukkandan 3 years ago
parent 90137ca4be
commit cb96c5be70
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39

@ -1815,7 +1815,7 @@ class YoutubeDL(object):
ie_result['entries'] = playlist_results
# Write the updated info to json
if _infojson_written and self._write_info_json(
if _infojson_written is True and self._write_info_json(
'updated playlist', ie_result,
self.prepare_filename(ie_copy, 'pl_infojson'), overwrite=True) is None:
return
@ -3786,7 +3786,7 @@ class YoutubeDL(object):
return encoding
def _write_info_json(self, label, ie_result, infofn, overwrite=None):
''' Write infojson and returns True = written, False = skip, None = error '''
''' Write infojson and returns True = written, 'exists' = Already exists, False = skip, None = error '''
if overwrite is None:
overwrite = self.params.get('overwrites', True)
if not self.params.get('writeinfojson'):
@ -3798,14 +3798,15 @@ class YoutubeDL(object):
return None
elif not overwrite and os.path.exists(infofn):
self.to_screen(f'[info] {label.title()} metadata is already present')
else:
return 'exists'
self.to_screen(f'[info] Writing {label} metadata as JSON to: {infofn}')
try:
write_json_file(self.sanitize_info(ie_result, self.params.get('clean_infojson', True)), infofn)
return True
except (OSError, IOError):
self.report_error(f'Cannot write {label} metadata to JSON file {infofn}')
return None
return True
def _write_description(self, label, ie_result, descfn):
''' Write description and returns True = written, False = skip, None = error '''

Loading…
Cancel
Save