mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
Fix --no-overwrite
for playlist infojson
Fixes: https://github.com/yt-dlp/yt-dlp/issues/1467#issuecomment-1079922971
This commit is contained in:
parent
90137ca4be
commit
cb96c5be70
1 changed files with 11 additions and 10 deletions
|
@ -1815,7 +1815,7 @@ def get_entry(i):
|
||||||
ie_result['entries'] = playlist_results
|
ie_result['entries'] = playlist_results
|
||||||
|
|
||||||
# Write the updated info to json
|
# 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,
|
'updated playlist', ie_result,
|
||||||
self.prepare_filename(ie_copy, 'pl_infojson'), overwrite=True) is None:
|
self.prepare_filename(ie_copy, 'pl_infojson'), overwrite=True) is None:
|
||||||
return
|
return
|
||||||
|
@ -3786,7 +3786,7 @@ def get_encoding(self):
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
def _write_info_json(self, label, ie_result, infofn, overwrite=None):
|
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:
|
if overwrite is None:
|
||||||
overwrite = self.params.get('overwrites', True)
|
overwrite = self.params.get('overwrites', True)
|
||||||
if not self.params.get('writeinfojson'):
|
if not self.params.get('writeinfojson'):
|
||||||
|
@ -3798,14 +3798,15 @@ def _write_info_json(self, label, ie_result, infofn, overwrite=None):
|
||||||
return None
|
return None
|
||||||
elif not overwrite and os.path.exists(infofn):
|
elif not overwrite and os.path.exists(infofn):
|
||||||
self.to_screen(f'[info] {label.title()} metadata is already present')
|
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:
|
self.to_screen(f'[info] Writing {label} metadata as JSON to: {infofn}')
|
||||||
write_json_file(self.sanitize_info(ie_result, self.params.get('clean_infojson', True)), infofn)
|
try:
|
||||||
except (OSError, IOError):
|
write_json_file(self.sanitize_info(ie_result, self.params.get('clean_infojson', True)), infofn)
|
||||||
self.report_error(f'Cannot write {label} metadata to JSON file {infofn}')
|
return True
|
||||||
return None
|
except (OSError, IOError):
|
||||||
return True
|
self.report_error(f'Cannot write {label} metadata to JSON file {infofn}')
|
||||||
|
return None
|
||||||
|
|
||||||
def _write_description(self, label, ie_result, descfn):
|
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 '''
|
||||||
|
|
Loading…
Reference in a new issue