def _finish_frag_download(self, ctx, info_dict):
    ctx['dest_stream'].close()
    if self.__do_ytdl_file(ctx):
        ytdl_filename = encodeFilename(self.ytdl_filename(ctx['filename']))
        if os.path.isfile(ytdl_filename):
            self.try_remove(ytdl_filename)
    elapsed = (time.time() - ctx['started'])
    if (ctx['tmpfilename'] == '-'):
        downloaded_bytes = ctx['complete_frags_downloaded_bytes']
    else:
        self.try_rename(ctx['tmpfilename'], ctx['filename'])
        if self.params.get('updatetime', True):
            filetime = ctx.get('fragment_filetime')
            if filetime:
                with contextlib.suppress(Exception):
                    os.utime(ctx['filename'], (time.time(), filetime))
        downloaded_bytes = os.path.getsize(encodeFilename(ctx['filename']))
    self._hook_progress({'downloaded_bytes': downloaded_bytes, 'total_bytes': downloaded_bytes, 'filename': ctx['filename'], 'status': 'finished', 'elapsed': elapsed, 'ctx_id': ctx.get('ctx_id'), 'max_progress': ctx.get('max_progress'), 'progress_idx': ctx.get('progress_idx')}, info_dict)
def _finish_frag_download(self, ctx, info_dict):
    ctx['dest_stream'].close()
    if self.__do_ytdl_file(ctx):
        ytdl_filename = encodeFilename(self.ytdl_filename(ctx['filename']))
        if os.path.isfile(ytdl_filename):
            self.try_remove(ytdl_filename)
    elapsed = (time.time() - ctx['started'])
    if (ctx['tmpfilename'] == '-'):
        downloaded_bytes = ctx['complete_frags_downloaded_bytes']
    else:
        self.try_rename(ctx['tmpfilename'], ctx['filename'])
        if self.params.get('updatetime', True):
            filetime = ctx.get('fragment_filetime')
            if filetime:
                with contextlib.suppress(Exception):
                    os.utime(ctx['filename'], (time.time(), filetime))
        downloaded_bytes = os.path.getsize(encodeFilename(ctx['filename']))
    self._hook_progress({'downloaded_bytes': downloaded_bytes, 'total_bytes': downloaded_bytes, 'filename': ctx['filename'], 'status': 'finished', 'elapsed': elapsed, 'ctx_id': ctx.get('ctx_id'), 'max_progress': ctx.get('max_progress'), 'progress_idx': ctx.get('progress_idx')}, info_dict)