(userId, cookies, video_pointer, scores)
| 75 | |
| 76 | |
| 77 | def video(userId, cookies, video_pointer, scores): |
| 78 | try: |
| 79 | if scores["video_num"] < const.video_num_all or scores["video_time"] < const.video_time_all: |
| 80 | # driver_video = Mydriver(nohead=nohead) |
| 81 | driver_video = Mydriver(nohead=True) |
| 82 | # def video_stop_function(): |
| 83 | # driver_video.quit() |
| 84 | # threads.regist_stop_function(video_stop_function) |
| 85 | driver_video.get_url("https://www.xuexi.cn/notFound.html") |
| 86 | driver_video.set_cookies(cookies) |
| 87 | links = get_links.get_video_links() |
| 88 | try_count = 0 |
| 89 | watchvideo_time = 0 |
| 90 | while True: |
| 91 | if scores["video_num"] < const.video_num_all and try_count < 10: |
| 92 | v_num = const.video_num_all - scores["video_num"] |
| 93 | for i in range(video_pointer, video_pointer + v_num): |
| 94 | driver_video.get_url(links[i]) |
| 95 | watchvideo_time = 60 + random.randint(5, 15) |
| 96 | for j in range(watchvideo_time): |
| 97 | if random.random() > 0.5: |
| 98 | driver_video.go_js('window.scrollTo(0, document.body.scrollHeight/180*{})'.format(j)) |
| 99 | print("\r视频数量学 xi 中,视频剩余{}个,本次剩余时间{}秒".format(video_pointer + v_num - i, watchvideo_time - j), end="") |
| 100 | time.sleep(1) |
| 101 | driver_video.go_js('window.scrollTo(0, document.body.scrollHeight)') |
| 102 | total, scores = show_score(cookies) |
| 103 | if scores["video_num"] >= const.video_num_all: |
| 104 | print("检测到视频数量分数已满,退出学 xi ") |
| 105 | break |
| 106 | video_pointer += v_num |
| 107 | else: |
| 108 | user.save_video_index(userId, video_pointer) |
| 109 | break |
| 110 | try_count = 0 |
| 111 | while True: |
| 112 | if scores["video_time"] < const.video_time_all and try_count < 10: |
| 113 | num_time = 60 |
| 114 | driver_video.get_url(links[video_pointer - 1]) |
| 115 | remaining = (const.video_time_all - scores["video_time"]) * 1 * num_time |
| 116 | for i in range(remaining): |
| 117 | if random.random() > 0.5: |
| 118 | driver_video.go_js( |
| 119 | 'window.scrollTo(0, document.body.scrollHeight/{}*{})'.format(remaining, i)) |
| 120 | print("\r视频时长学 xi 中,视频总时长剩余{}秒".format(remaining - i), end="") |
| 121 | time.sleep(1) |
| 122 | if i % (60) == 0 and i != remaining: |
| 123 | total, scores = show_score(cookies) |
| 124 | if scores["video_time"] >= const.video_time_all: |
| 125 | print("检测到视频时长分数已满,退出学 xi ") |
| 126 | break |
| 127 | driver_video.go_js('window.scrollTo(0, document.body.scrollHeight)') |
| 128 | total, scores = show_score(cookies) |
| 129 | else: |
| 130 | break |
| 131 | if try_count < 10: |
| 132 | print("视频学 xi 完成") |
| 133 | else: |
| 134 | print("视频学 xi 出现异常,请检查 user/article_video_index.json 文件记录") |
nothing calls this directly
no test coverage detected