Beispiel #1
0
 def login(self, args):
     """登录网盘"""
     if args:
         if '--auto' in args:
             if config.cookie and self._disk.login_by_cookie(config) == Cloud189.SUCCESS:
                 self.refresh(config.work_id, auto=True)
                 return None
     username = input('输入用户名:')
     password = getpass('输入密码:')
     if not username or not password:
         error('没有用户名或密码 :(')
         return None
     code = self._disk.login(username, password)
     if code == Cloud189.NETWORK_ERROR:
         error("登录失败,网络连接异常")
         return None
     elif code == Cloud189.FAILED:
         error('登录失败,用户名或密码错误 :(')
         return None
     # 登录成功保存用户 cookie
     config.username = username
     config.password = password
     config.cookie = self._disk.get_cookie()
     code, token = get_token(username, password)
     if code == Cloud189.SUCCESS:
         config.set_token(*token)
         self._disk.set_session(*token)
     self._work_id = -11
     self.refresh(-11)
Beispiel #2
0
 def login(self):
     """登录网盘"""
     if not config.cookie or self._disk.login_by_cookie(config) != Cloud189.SUCCESS:
         username = input('输入用户名:')
         password = getpass('输入密码:')
         code = self._disk.login(username, password)
         if code == Cloud189.NETWORK_ERROR:
             error("登录失败,网络连接异常")
             return None
         elif code == Cloud189.FAILED:
             error('登录失败,用户名或密码错误 :(')
             return None
         # 登录成功保存用户 cookie
         config.username = username
         config.password = password
         config.cookie = self._disk.get_cookie()
         code, token = get_token(username, password)
         if code == Cloud189.SUCCESS:
             config.set_token(*token)
             self._disk.set_session(*token)
     self.refresh()