def down(command): if not api.checkLogin(): print('You should login first') login('login') command = command[1:] ids = {} for i in command: path,filename = os.path.split(i) ret =[(f['fs_id'],filename) for f in api.getFileList(path) if f['server_filename'] == filename and not f['isdir']] if ret: ids[ret[0][0]] = {'filename':ret[0][1]} else: print('Get {} info failed'.format(utils.shortStr(i,25))) ret = api.getFilesLink(ids.keys()) # print(ids) for i in ret: ids[int(i['fs_id'])]['link'] = i['dlink'] # print(ids) downloader.download(ids.values())
def download(self,files): for i in files: url = api.r.get(i['link'],allow_redirects=False).headers['Location'] self.s.aria2.addUri([url],{'out':i['filename']}) print('Add {} Success'.format(utils.shortStr(i['filename'],60)))