|
|
@ -58,6 +58,7 @@ from .utils import (
|
|
|
|
encode_compat_str,
|
|
|
|
encode_compat_str,
|
|
|
|
encodeFilename,
|
|
|
|
encodeFilename,
|
|
|
|
error_to_compat_str,
|
|
|
|
error_to_compat_str,
|
|
|
|
|
|
|
|
ExistingVideoReached,
|
|
|
|
expand_path,
|
|
|
|
expand_path,
|
|
|
|
ExtractorError,
|
|
|
|
ExtractorError,
|
|
|
|
format_bytes,
|
|
|
|
format_bytes,
|
|
|
@ -81,6 +82,7 @@ from .utils import (
|
|
|
|
register_socks_protocols,
|
|
|
|
register_socks_protocols,
|
|
|
|
render_table,
|
|
|
|
render_table,
|
|
|
|
replace_extension,
|
|
|
|
replace_extension,
|
|
|
|
|
|
|
|
RejectedVideoReached,
|
|
|
|
SameFileError,
|
|
|
|
SameFileError,
|
|
|
|
sanitize_filename,
|
|
|
|
sanitize_filename,
|
|
|
|
sanitize_path,
|
|
|
|
sanitize_path,
|
|
|
@ -232,6 +234,7 @@ class YoutubeDL(object):
|
|
|
|
again.
|
|
|
|
again.
|
|
|
|
break_on_existing: Stop the download process after attempting to download a file that's
|
|
|
|
break_on_existing: Stop the download process after attempting to download a file that's
|
|
|
|
in the archive.
|
|
|
|
in the archive.
|
|
|
|
|
|
|
|
break_on_reject: Stop the download process when encountering a video that has been filtered out.
|
|
|
|
cookiefile: File name where cookies should be read from and dumped to.
|
|
|
|
cookiefile: File name where cookies should be read from and dumped to.
|
|
|
|
nocheckcertificate:Do not verify SSL certificates
|
|
|
|
nocheckcertificate:Do not verify SSL certificates
|
|
|
|
prefer_insecure: Use HTTP instead of HTTPS to retrieve information.
|
|
|
|
prefer_insecure: Use HTTP instead of HTTPS to retrieve information.
|
|
|
@ -797,6 +800,7 @@ class YoutubeDL(object):
|
|
|
|
def _match_entry(self, info_dict, incomplete):
|
|
|
|
def _match_entry(self, info_dict, incomplete):
|
|
|
|
""" Returns None if the file should be downloaded """
|
|
|
|
""" Returns None if the file should be downloaded """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_filter():
|
|
|
|
video_title = info_dict.get('title', info_dict.get('id', 'video'))
|
|
|
|
video_title = info_dict.get('title', info_dict.get('id', 'video'))
|
|
|
|
if 'title' in info_dict:
|
|
|
|
if 'title' in info_dict:
|
|
|
|
# This can happen when we're just evaluating the playlist
|
|
|
|
# This can happen when we're just evaluating the playlist
|
|
|
@ -833,9 +837,17 @@ class YoutubeDL(object):
|
|
|
|
ret = match_filter(info_dict)
|
|
|
|
ret = match_filter(info_dict)
|
|
|
|
if ret is not None:
|
|
|
|
if ret is not None:
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reason = check_filter()
|
|
|
|
|
|
|
|
if reason is not None:
|
|
|
|
|
|
|
|
self.to_screen('[download] ' + reason)
|
|
|
|
|
|
|
|
if reason.endswith('has already been recorded in the archive') and self.params.get('break_on_existing'):
|
|
|
|
|
|
|
|
raise ExistingVideoReached()
|
|
|
|
|
|
|
|
elif self.params.get('break_on_reject'):
|
|
|
|
|
|
|
|
raise RejectedVideoReached()
|
|
|
|
|
|
|
|
return reason
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@staticmethod
|
|
|
|
def add_extra_info(info_dict, extra_info):
|
|
|
|
def add_extra_info(info_dict, extra_info):
|
|
|
|
'''Set the keys from extra_info in info dict if they are missing'''
|
|
|
|
'''Set the keys from extra_info in info dict if they are missing'''
|
|
|
@ -895,7 +907,7 @@ class YoutubeDL(object):
|
|
|
|
self.report_error(msg)
|
|
|
|
self.report_error(msg)
|
|
|
|
except ExtractorError as e: # An error we somewhat expected
|
|
|
|
except ExtractorError as e: # An error we somewhat expected
|
|
|
|
self.report_error(compat_str(e), e.format_traceback())
|
|
|
|
self.report_error(compat_str(e), e.format_traceback())
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
except (MaxDownloadsReached, ExistingVideoReached, RejectedVideoReached):
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
if self.params.get('ignoreerrors', False):
|
|
|
|
if self.params.get('ignoreerrors', False):
|
|
|
@ -1098,14 +1110,7 @@ class YoutubeDL(object):
|
|
|
|
'extractor_key': ie_result['extractor_key'],
|
|
|
|
'extractor_key': ie_result['extractor_key'],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reason = self._match_entry(entry, incomplete=True)
|
|
|
|
self._match_entry(entry, incomplete=True)
|
|
|
|
if reason is not None:
|
|
|
|
|
|
|
|
if reason.endswith('has already been recorded in the archive') and self.params.get('break_on_existing'):
|
|
|
|
|
|
|
|
print('[download] tried downloading a file that\'s already in the archive, stopping since --break-on-existing is set.')
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.to_screen('[download] ' + reason)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entry_result = self.__process_iterable_entry(entry, download, extra)
|
|
|
|
entry_result = self.__process_iterable_entry(entry, download, extra)
|
|
|
|
# TODO: skip failed (empty) entries?
|
|
|
|
# TODO: skip failed (empty) entries?
|
|
|
@ -1870,9 +1875,7 @@ class YoutubeDL(object):
|
|
|
|
if 'format' not in info_dict:
|
|
|
|
if 'format' not in info_dict:
|
|
|
|
info_dict['format'] = info_dict['ext']
|
|
|
|
info_dict['format'] = info_dict['ext']
|
|
|
|
|
|
|
|
|
|
|
|
reason = self._match_entry(info_dict, incomplete=False)
|
|
|
|
if self._match_entry(info_dict, incomplete=False) is not None:
|
|
|
|
if reason is not None:
|
|
|
|
|
|
|
|
self.to_screen('[download] ' + reason)
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
self._num_downloads += 1
|
|
|
|
self._num_downloads += 1
|
|
|
@ -2260,7 +2263,13 @@ class YoutubeDL(object):
|
|
|
|
except UnavailableVideoError:
|
|
|
|
except UnavailableVideoError:
|
|
|
|
self.report_error('unable to download video')
|
|
|
|
self.report_error('unable to download video')
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
except MaxDownloadsReached:
|
|
|
|
self.to_screen('[info] Maximum number of downloaded files reached.')
|
|
|
|
self.to_screen('[info] Maximum number of downloaded files reached')
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
except ExistingVideoReached:
|
|
|
|
|
|
|
|
self.to_screen('[info] Encountered a file that did not match filter, stopping due to --break-on-reject')
|
|
|
|
|
|
|
|
raise
|
|
|
|
|
|
|
|
except RejectedVideoReached:
|
|
|
|
|
|
|
|
self.to_screen('[info] Encountered a file that is already in the archive, stopping due to --break-on-existing')
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if self.params.get('dump_single_json', False):
|
|
|
|
if self.params.get('dump_single_json', False):
|
|
|
|