def login(command): if api.checkLogin(): return username = input('Username:'******'logining, please wait for a while....') try: api.login(username, password) except error.ApiError: print('Login Failed! Check your username & password please.')
def init(): global Config Config = loadConfig() api.loadCookie(Config.get('cookies')) if not api.checkLogin(): print('Seems you are not logined.') print("Let's Login First") username = input('Username:'******'Password:'******'Init Finished.')
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())