def add_task(self, pcs_file, dirname='<STR_LIT>'):
if pcs_file['<STR_LIT>']:<EOL><INDENT>return<EOL><DEDENT>fs_id = str(pcs_file['<STR_LIT>'])<EOL>row = self.get_row_by_fsid(fs_id)<EOL>if row:<EOL><INDENT>self.app.toast(_('<STR_LIT>').format(<EOL>pcs_file['<STR_LIT>']))<EOL>if row[STATE_COL] == State.FINISHED:<EOL><INDENT>self.launch_app(fs_id)<EOL><DEDENT>return<EOL><DEDENT>if not dirname:<EOL><INDENT>dirname = self.app.profile['<STR_LIT>']<EOL><DEDENT>save_dir = os.path.dirname(<EOL>os.path.join(dirname, pcs_file['<STR_LIT:path>'][<NUM_LIT:1>:]))<EOL>save_name = pcs_file['<STR_LIT>']<EOL>human_size = util.get_human_size(pcs_file['<STR_LIT:size>'])[<NUM_LIT:0>]<EOL>tooltip = gutil.escape(_('<STR_LIT>').format(pcs_file['<STR_LIT:path>'],<EOL>save_dir))<EOL>task = (<EOL>pcs_file['<STR_LIT>'],<EOL>pcs_file['<STR_LIT:path>'],<EOL>fs_id,<EOL>pcs_file['<STR_LIT:size>'],<EOL><NUM_LIT:0>,<EOL>'<STR_LIT>',  <EOL>pcs_file['<STR_LIT>'],<EOL>save_name,<EOL>save_dir,<EOL>State.WAITING,<EOL>StateNames[State.WAITING],<EOL>human_size,<EOL><NUM_LIT:0>,<EOL>tooltip,<EOL>)<EOL>self.liststore.append(task)<EOL>self.add_task_db(task)<EOL>self.scan_tasks()<EOL>
加入新的下载任务