[fragment] Print error message when skipping fragment

This commit is contained in:
pukkandan 2021-10-19 21:51:33 +05:30
parent 2cda6b401d
commit b4b855ebc7
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
2 changed files with 7 additions and 6 deletions

View file

@ -152,11 +152,11 @@ def _call_downloader(self, tmpfilename, info_dict):
fragment_filename = '%s-Frag%d' % (tmpfilename, frag_index) fragment_filename = '%s-Frag%d' % (tmpfilename, frag_index)
try: try:
src, _ = sanitize_open(fragment_filename, 'rb') src, _ = sanitize_open(fragment_filename, 'rb')
except IOError: except IOError as err:
if skip_unavailable_fragments and frag_index > 1: if skip_unavailable_fragments and frag_index > 1:
self.to_screen('[%s] Skipping fragment %d ...' % (self.get_basename(), frag_index)) self.report_skip_fragment(frag_index, err)
continue continue
self.report_error('Unable to open fragment %d' % frag_index) self.report_error(f'Unable to open fragment {frag_index}; {err}')
return -1 return -1
dest.write(decrypt_fragment(fragment, src.read())) dest.write(decrypt_fragment(fragment, src.read()))
src.close() src.close()

View file

@ -72,8 +72,9 @@ def report_retry_fragment(self, err, frag_index, count, retries):
'\r[download] Got server HTTP error: %s. Retrying fragment %d (attempt %d of %s) ...' '\r[download] Got server HTTP error: %s. Retrying fragment %d (attempt %d of %s) ...'
% (error_to_compat_str(err), frag_index, count, self.format_retries(retries))) % (error_to_compat_str(err), frag_index, count, self.format_retries(retries)))
def report_skip_fragment(self, frag_index): def report_skip_fragment(self, frag_index, err=None):
self.to_screen('[download] Skipping fragment %d ...' % frag_index) err = f' {err};' if err else ''
self.to_screen(f'[download]{err} Skipping fragment {frag_index:d} ...')
def _prepare_url(self, info_dict, url): def _prepare_url(self, info_dict, url):
headers = info_dict.get('http_headers') headers = info_dict.get('http_headers')
@ -443,7 +444,7 @@ def download_fragment(fragment, ctx):
def append_fragment(frag_content, frag_index, ctx): def append_fragment(frag_content, frag_index, ctx):
if not frag_content: if not frag_content:
if not is_fatal(frag_index - 1): if not is_fatal(frag_index - 1):
self.report_skip_fragment(frag_index) self.report_skip_fragment(frag_index, 'fragment not found')
return True return True
else: else:
ctx['dest_stream'].close() ctx['dest_stream'].close()