Ejemplo n.º 1
0
    #  1 创建用户标记,区分多个用户历史纪录
    uid = user.get_default_userId()
    if not cookies:
        print("未找到有效登录信息,需要登录")
        driver_login = Mydriver(nohead=False)
        cookies = driver_login.login()
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        user.update_last_user(uid)
        try:
            driver_login.quit()
        except:
            print("wtf:退出webdriver失败?")
            pass
    article_index = user.get_article_index(uid)
    video_index = user.get_video_index(uid)

    total, scores = show_score(cookies)
    nohead, lock, stime = get_argv()

    article_thread = threads.MyThread("文章学习",
                                      article,
                                      uid,
                                      cookies,
                                      article_index,
                                      scores,
                                      lock=lock)
    article_thread.start()
    article_thread.join()
Ejemplo n.º 2
0
def start_learn(uid, name):
    nohead, lock, stime = get_argv()
    print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead')))
    cookies = user.get_cookie(uid)
    if nohead == True:
        TechXueXi_mode = "3"
    else:
        try:
            if cfg["base"]["ModeType"]:
                print("默认选择模式:" + str(cfg["base"]["ModeType"]) + "\n" +
                      "=" * 60)
                TechXueXi_mode = str(cfg["base"]["ModeType"])
        except Exception as e:
            TechXueXi_mode = "3"
    if not name:
        user_fullname = user.get_fullname(uid)
    else:
        user_fullname = uid + "_" + name
    if not cookies or TechXueXi_mode == "0":
        msg = ""
        if name == "新用户":
            msg = "需要增加新用户,请扫码登录,否则请无视"
        else:
            msg = user_fullname + "登录信息失效,请重新扫码"
        print(msg)
        gl.pushprint(msg)
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        if not cookies:
            print("登录超时")
            return
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        user.update_last_user(uid)
    output = "\n用户:" + user_fullname + "登录正常,开始学习...\n"

    article_index = user.get_article_index(uid)
    video_index = 1  # user.get_video_index(uid)

    total, scores = show_score(cookies)
    gl.pushprint(output)
    if TechXueXi_mode in ["1", "3"]:

        article_thread = threads.MyThread("文章学 xi ",
                                          article,
                                          uid,
                                          cookies,
                                          article_index,
                                          scores,
                                          lock=lock)
        video_thread = threads.MyThread("视频学 xi ",
                                        video,
                                        uid,
                                        cookies,
                                        video_index,
                                        scores,
                                        lock=lock)
        article_thread.start()
        video_thread.start()
        article_thread.join()
        video_thread.join()
    if TechXueXi_mode in ["2", "3"]:
        driver_default = Mydriver()
        print('开始每日答题……')
        daily(cookies, scores, driver_default=driver_default)
        if TechXueXi_mode in ["2", "3"]:
            print('开始每周答题……')
            weekly(cookies, scores, driver_default=driver_default)
            if nohead != True:
                print('开始专项答题……')
                zhuanxiang(cookies, scores, driver_default=driver_default)
        try:
            driver_default.quit()
        except Exception as e:
            gl.pushprint('driver_default 在 main 退出时出了一点小问题...')
    if TechXueXi_mode == "4":
        user.select_user()
    if TechXueXi_mode == "5":
        user.refresh_all_cookies(display_score=True)
    if TechXueXi_mode == "6":
        user.refresh_all_cookies(live_time=11.90)

    seconds_used = int(time.time() - start_time)
    print("总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " +
          str(seconds_used % 60) + " 秒")
    show_scorePush(cookies)
    try:
        user.shutdown(stime)
    except Exception as e:
        pass
Ejemplo n.º 3
0
def start_learn(uid, name):
    #  0 读取版本信息
    start_time = time.time()
    nohead, lock, stime, Single = get_argv()
    print("是否无头模式:{0} {1}".format(nohead, os.getenv('Nohead')))
    cookies = user.get_cookie(uid)
    if nohead == True:
        TechXueXi_mode = "3"
    else:
        TechXueXi_mode = str(cfg_get("base.ModeType", 3))
        print("当前选择模式:" + TechXueXi_mode + "\n" + "=" * 60)

    if not name:
        user_fullname = user.get_fullname(uid)
        name = user_fullname.split('_', 1)[1]
    else:
        user_fullname = uid + "_" + name

    if not cookies or TechXueXi_mode == "0":
        msg = ""
        if name == "新用户":
            msg = "需要增加新用户,请扫码登录,否则请无视"
        else:
            msg = name + " 登录信息失效,请重新扫码"
        # print(msg)
        gl.pushprint(msg, chat_id=uid)
        if gl.pushmode == "6":
            gl.pushprint("web模式跳过自动获取二维码,请手动点击添加按钮", chat_id=uid)
            print(color.red("【#️⃣】 若直接退出请运行:webserverListener.py"))
            return
        driver_login = Mydriver()
        cookies = driver_login.login()
        driver_login.quit()
        if not cookies:
            print("登录超时")
            return
        user.save_cookies(cookies)
        uid = user.get_userId(cookies)
        user_fullname = user.get_fullname(uid)
        name = user_fullname.split('_', 1)[1]
        user.update_last_user(uid)
    output = name + " 登录正常,开始学习...\n"

    article_index = user.get_article_index(uid)
    video_index = 1  # user.get_video_index(uid)

    total, scores = show_score(cookies)
    gl.pushprint(output, chat_id=uid)
    if TechXueXi_mode in ["1", "3"]:

        article_thread = threads.MyThread("文章学 xi ",
                                          article,
                                          uid,
                                          cookies,
                                          article_index,
                                          scores,
                                          lock=lock)
        video_thread = threads.MyThread("视频学 xi ",
                                        video,
                                        uid,
                                        cookies,
                                        video_index,
                                        scores,
                                        lock=lock)
        article_thread.start()
        video_thread.start()
        article_thread.join()
        video_thread.join()
    if TechXueXi_mode in ["2", "3"]:
        print('开始每日答题……')
        daily(cookies, scores)
        print('开始每周答题……')
        weekly(cookies, scores)
        if nohead != True or gl.zhuanxiang == True:
            print('开始专项答题……')
            zhuanxiang(cookies, scores)

    if TechXueXi_mode == "4":
        user.select_user()
    if TechXueXi_mode == "5":
        user.refresh_all_cookies(display_score=True)
    if TechXueXi_mode == "6":
        user.refresh_all_cookies(live_time=11.90)

    seconds_used = int(time.time() - start_time)
    gl.pushprint(name + " 总计用时 " + str(math.floor(seconds_used / 60)) + " 分 " +
                 str(seconds_used % 60) + " 秒",
                 chat_id=uid)
    show_scorePush(cookies, chat_id=uid)
    try:
        user.shutdown(stime)
    except Exception as e:
        pass