Beispiel #1
0
    def __Check_Project_Answer(self) -> None:
        """
        __Check_Project_Answer() -> None
        监测专项答题任务的完成

        :return: None
        """
        while True:
            bar = INFO_MANAGE().Task_Bar
            if bar[4].Current_Score != bar[4].Day_Max_Score:
                if self.__answer_time[-1]:
                    if time.time() - self.__answer_time[0] <= 10:
                        continue
                token = self.__driver.get_cookie(name='token')['value']
                iid = TASK_INIT().Assigning_Project_Answer(token=token)
                if not iid:
                    print("没有专项答题任务了")
                    break
                temp = TASK_ANSWER(driver=self.__driver)
                try:
                    temp.Do(link=API().Project_Answer_Topic.geturl().format(num=iid))
                except TASK_EXCEPTION:
                    DB_MANAGE().Project.Insert(PROJECT(pid=iid))
                OUTPUT.Info()
                self.__answer_time = (time.time(), True)
            else:
                break
Beispiel #2
0
 def _Login(self) -> bool:
     """
     _Login() -> Bool
     进行登录;
     具体流程:
         1、开启循环检测二维码状态
             1、获取二维码图片
             2、显示二维码
             3、二维码状态检测
             4、根据3的返回值决定:
                 1、刷新二维码,中断本次循环,再来一次
                 2、提取Token值,根据选项(持久化)决定是否保持token,关闭二维码容器
     :return: Bool,返回值只有True,如未登录则会一直循环
     """
     self.__network.Clear()
     self.__driver.get(url=API().Login.geturl())
     while True:
         qr = self.__Get_QR()
         QR_VESSEL().Show_QR(qr=qr)
         status = self.__Check_Status()
         if not status:
             self.__QR_Refresh()
             continue
         else:
             while self.__driver.current_url != API().Master.geturl():
                 continue
             cookies = self.__driver.get_cookies()
             token = [{cookie['name']: cookie['value']} for cookie in
                      cookies if cookie['name'] == 'token']
             if token:
                 INFO_MANAGE().Init(token=token[0]['token'])
                 if OPTIONS().Token:
                     cookie = token[0]
                     html = REQUESTS().Get(
                         url=API().Aggregate_Score.geturl(),
                         cookies=cookie
                     )
                     data = html.json()
                     user_id = data['data']['userId']
                     user = USER(user_id=user_id, token=token[0]['token'])
                     if DB_MANAGE().User.Exist_User(user=user):
                         DB_MANAGE().User.Update(user=user)
                     else:
                         DB_MANAGE().User.Insert(user=user)
                         DB_MANAGE().Article.Update_All()
                         DB_MANAGE().Video.Update_All()
             QR_VESSEL().QR_QUIT()
             return status
Beispiel #3
0
 def Info(cls):
     os.system(command=SYSTEM().Clear)
     temp = INFO_MANAGE()
     level = temp.Level_Info
     print(f"项目地址:https://github.com/lisztomania-Zero/learning-power")
     print(f"用户ID:{temp.Id}\n"
           f"等级:{level[0]}\t段位:{level[1]}\t全国排名:{level[2]}\n"
           f"总积分:{temp.Aggregate_Score}\t今日积分:{temp.Daily_Score}\n"
           f"每日积分细则:")
     print()
     for index, value in enumerate(list(temp.Task_Bar.values())):
         if (index + 1) % 5 == 0:
             print(f"{value.Name}:{value.Current_Score}分")
             continue
         print(f"{value.Name}:{value.Current_Score}分\t", end='')
     print('\n')
Beispiel #4
0
    def Login(self) -> bool:
        """
        Login() -> bool
        登录,如果user表不为空会检测令牌是否有效,有效则直接登录

        :return: bool
        """
        if DB_MANAGE().User.Exist():
            user = DB_MANAGE().User.Query()
            if CHECK_TOKEN.Check_Token(token=user.Token):
                INFO_MANAGE().Init(token=user.Token)
                self.__driver.get(url=API().Master.geturl())
                self.__driver.add_cookie(cookie_dict=user.Token_Driver)
                self.__driver.refresh()
                return True
        return self._Login()
Beispiel #5
0
    def __Check_Article(self) -> None:
        """
        __Check_Article() -> None
        监测文章任务的完成

        :return: None
        """
        while True:
            bar = INFO_MANAGE().Task_Bar
            p = bar[1].Day_Max_Score - bar[1].Current_Score
            c = bar[1002].Day_Max_Score - bar[1002].Current_Score
            if p and not c:
                self.__Article(num=p, tq=1)
            elif p and c:
                self.__Article(num=p, tq=(c*4)//p)
            elif not p and c:
                self.__Article(num=1, tq=c*4)
            else:
                break
Beispiel #6
0
    def __Check_Daily_Answer(self) -> None:
        """
        __Check_Daily_Answer() -> None
        监测每日答题任务的完成

        :return: None
        """
        while True:
            bar = INFO_MANAGE().Task_Bar
            if bar[6].Current_Score != bar[6].Day_Max_Score:
                if self.__answer_time[-1]:
                    if time.time() - self.__answer_time[0] <= 10:
                        continue
                temp = TASK_ANSWER(driver=self.__driver)
                temp.Do(link=API().Daily_Answer.geturl())
                OUTPUT.Info()
                self.__answer_time = (time.time(), True)
            else:
                break