def prepare_zip_file(th, torrent_name, files, event, log): downloaded_pieces_count = 0 torrent_files = [] num_pieces = 0 for fi in files: num_pieces += fi.num_pieces # for i, fi in enumerate(files): # if i != 0: # downloaded_pieces_count += files[i-1].num_pieces # cur_status_msg_text = status_msg_text.format(cur_file_progress=status_msg_current_file_text.format(cur_file_name=fi.name[0:25] + ("..." if len(fi.name)>25 else ""))) # callback = lambda cur_piece, _num_pieces=fi.num_pieces, _downloaded_pieces_count=downloaded_pieces_count, __num_pieces=num_pieces, _status_msg=status_msg, _cur_status_msg_text=cur_status_msg_text: progress_callback(cur_piece, _num_pieces, _downloaded_pieces_count, __num_pieces, _status_msg, _cur_status_msg_text) torrent_files.append(tc.TorrentContentFile(th, fi, log)) zip_progress_text = prepare_status_message(files, torrent_name, th.total_size()) callback = lambda percent: \ event.edit(zip_progress_text.format(percent), buttons=[Button.inline('Cancel', str(event.sender_id))]) zfile = tc.ZipTorrentContentFile(th, torrent_files, torrent_name, callback, log, should_split=True) return zfile
def next_file(self): file_info = next(self.files) if file_info.size > const.TG_MAX_FILE_SIZE: files = [{}] # return ZipTorrentContentFile(files) else: file = tc.TorrentContentFile(self.torrent_handle, file_info.num_pieces, file_info.size, self.callback)