mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 00:01:54 +01:00
Compare commits
3 Commits
9014bbda7e
...
a265a16a73
Author | SHA1 | Date | |
---|---|---|---|
|
a265a16a73 | ||
|
eee4f7163d | ||
|
8f35b886d9 |
|
@ -1470,7 +1470,8 @@ class YoutubeDL:
|
||||||
return self.get_output_path(dir_type, filename)
|
return self.get_output_path(dir_type, filename)
|
||||||
|
|
||||||
def _match_entry(self, info_dict, incomplete=False, silent=False):
|
def _match_entry(self, info_dict, incomplete=False, silent=False):
|
||||||
"""Returns None if the file should be downloaded"""
|
"""Returns None if the file should be downloaded, False if the file is already present in
|
||||||
|
the download archive, or a string describing another reason to skip the file"""
|
||||||
_type = 'video' if 'playlist-match-filter' in self.params['compat_opts'] else info_dict.get('_type', 'video')
|
_type = 'video' if 'playlist-match-filter' in self.params['compat_opts'] else info_dict.get('_type', 'video')
|
||||||
assert incomplete or _type == 'video', 'Only video result can be considered complete'
|
assert incomplete or _type == 'video', 'Only video result can be considered complete'
|
||||||
|
|
||||||
|
@ -1545,6 +1546,7 @@ class YoutubeDL:
|
||||||
format_field(info_dict, 'id', f'{self._format_screen("%s", self.Styles.ID)}: '),
|
format_field(info_dict, 'id', f'{self._format_screen("%s", self.Styles.ID)}: '),
|
||||||
format_field(info_dict, 'title', f'{self._format_screen("%s", self.Styles.EMPHASIS)} '),
|
format_field(info_dict, 'title', f'{self._format_screen("%s", self.Styles.EMPHASIS)} '),
|
||||||
'has already been recorded in the archive'))
|
'has already been recorded in the archive'))
|
||||||
|
ret = False
|
||||||
break_opt, break_err = 'break_on_existing', ExistingVideoReached
|
break_opt, break_err = 'break_on_existing', ExistingVideoReached
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -1553,12 +1555,13 @@ class YoutubeDL:
|
||||||
reason, break_opt, break_err = e.msg, 'match_filter', type(e)
|
reason, break_opt, break_err = e.msg, 'match_filter', type(e)
|
||||||
else:
|
else:
|
||||||
break_opt, break_err = 'break_on_reject', RejectedVideoReached
|
break_opt, break_err = 'break_on_reject', RejectedVideoReached
|
||||||
|
ret = reason
|
||||||
if reason is not None:
|
if reason is not None:
|
||||||
if not silent:
|
if not silent:
|
||||||
self.to_screen('[download] ' + reason)
|
self.to_screen('[download] ' + reason)
|
||||||
if self.params.get(break_opt, False):
|
if self.params.get(break_opt, False):
|
||||||
raise break_err()
|
raise break_err()
|
||||||
return reason
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_extra_info(info_dict, extra_info):
|
def add_extra_info(info_dict, extra_info):
|
||||||
|
@ -1832,6 +1835,7 @@ class YoutubeDL:
|
||||||
self._raise_pending_errors(info_copy)
|
self._raise_pending_errors(info_copy)
|
||||||
if self.params.get('force_write_download_archive', False):
|
if self.params.get('force_write_download_archive', False):
|
||||||
self.record_download_archive(info_copy)
|
self.record_download_archive(info_copy)
|
||||||
|
ie_result['__write_download_archive'] = self.params.get('force_write_download_archive', False)
|
||||||
return ie_result
|
return ie_result
|
||||||
|
|
||||||
if result_type == 'video':
|
if result_type == 'video':
|
||||||
|
@ -1971,7 +1975,9 @@ class YoutubeDL:
|
||||||
|
|
||||||
common_info = self._playlist_infodict(ie_result, strict=True)
|
common_info = self._playlist_infodict(ie_result, strict=True)
|
||||||
title = common_info.get('playlist') or '<Untitled>'
|
title = common_info.get('playlist') or '<Untitled>'
|
||||||
if self._match_entry(common_info, incomplete=True) is not None:
|
skip_reason = self._match_entry(common_info, incomplete=True)
|
||||||
|
if skip_reason is not None:
|
||||||
|
ie_result['__write_download_archive'] = skip_reason is False
|
||||||
return
|
return
|
||||||
self.to_screen(f'[download] Downloading {ie_result["_type"]}: {title}')
|
self.to_screen(f'[download] Downloading {ie_result["_type"]}: {title}')
|
||||||
|
|
||||||
|
@ -2026,6 +2032,7 @@ class YoutubeDL:
|
||||||
self.write_debug('The information of all playlist entries will be held in memory')
|
self.write_debug('The information of all playlist entries will be held in memory')
|
||||||
|
|
||||||
failures = 0
|
failures = 0
|
||||||
|
all_write_download_archive = True
|
||||||
max_failures = self.params.get('skip_playlist_after_errors') or float('inf')
|
max_failures = self.params.get('skip_playlist_after_errors') or float('inf')
|
||||||
for i, (playlist_index, entry) in enumerate(entries):
|
for i, (playlist_index, entry) in enumerate(entries):
|
||||||
if lazy:
|
if lazy:
|
||||||
|
@ -2059,6 +2066,8 @@ class YoutubeDL:
|
||||||
}, extra))
|
}, extra))
|
||||||
if not entry_result:
|
if not entry_result:
|
||||||
failures += 1
|
failures += 1
|
||||||
|
elif not entry_result.get('__write_download_archive', False):
|
||||||
|
all_write_download_archive = False
|
||||||
if failures >= max_failures:
|
if failures >= max_failures:
|
||||||
self.report_error(
|
self.report_error(
|
||||||
f'Skipping the remaining entries in playlist "{title}" since {failures} items failed extraction')
|
f'Skipping the remaining entries in playlist "{title}" since {failures} items failed extraction')
|
||||||
|
@ -2073,6 +2082,12 @@ class YoutubeDL:
|
||||||
# Do not set for full playlist
|
# Do not set for full playlist
|
||||||
ie_result.pop('requested_entries')
|
ie_result.pop('requested_entries')
|
||||||
|
|
||||||
|
if ie_result['_type'] == 'multi_video' and not failures:
|
||||||
|
if self.params.get('force_write_download_archive') or (
|
||||||
|
all_write_download_archive and not self.params.get('simulate')
|
||||||
|
and not self.params.get('skip_download')):
|
||||||
|
self.record_download_archive(ie_result)
|
||||||
|
|
||||||
# Write the updated info to json
|
# Write the updated info to json
|
||||||
if _infojson_written is True and self._write_info_json(
|
if _infojson_written is True and self._write_info_json(
|
||||||
'updated playlist', ie_result,
|
'updated playlist', ie_result,
|
||||||
|
@ -2919,7 +2934,9 @@ class YoutubeDL:
|
||||||
|
|
||||||
info_dict, _ = self.pre_process(info_dict)
|
info_dict, _ = self.pre_process(info_dict)
|
||||||
|
|
||||||
if self._match_entry(info_dict, incomplete=self._format_fields) is not None:
|
skip_reason = self._match_entry(info_dict, incomplete=self._format_fields)
|
||||||
|
if skip_reason is not None:
|
||||||
|
info_dict['__write_download_archive'] = skip_reason is False
|
||||||
return info_dict
|
return info_dict
|
||||||
|
|
||||||
self.post_extract(info_dict)
|
self.post_extract(info_dict)
|
||||||
|
@ -3022,6 +3039,7 @@ class YoutubeDL:
|
||||||
assert write_archive.issubset({True, False, 'ignore'})
|
assert write_archive.issubset({True, False, 'ignore'})
|
||||||
if True in write_archive and False not in write_archive:
|
if True in write_archive and False not in write_archive:
|
||||||
self.record_download_archive(info_dict)
|
self.record_download_archive(info_dict)
|
||||||
|
info_dict['__write_download_archive'] = True
|
||||||
|
|
||||||
info_dict['requested_downloads'] = downloaded_formats
|
info_dict['requested_downloads'] = downloaded_formats
|
||||||
info_dict = self.run_all_pps('after_video', info_dict)
|
info_dict = self.run_all_pps('after_video', info_dict)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user