From eedf48d6df87651e1543d6d68d6fa8947d305c7d Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Thu, 21 May 2026 09:52:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AD=A5=E9=AA=A4=E2=91=A4:?= =?UTF-8?q?=20=E6=A3=80=E6=9F=A5=E5=B9=B6=E6=BF=80=E6=B4=BB=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E5=8D=95=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ef_course_autopilot.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ef_course_autopilot.py b/ef_course_autopilot.py index 0d98837..816596c 100755 --- a/ef_course_autopilot.py +++ b/ef_course_autopilot.py @@ -810,6 +810,44 @@ class EFCourseAutopilot: error=f"skip-exception: {e}", ) + # -------------------------------------------------------- + # 步骤⑤: 激活下一单元 + # -------------------------------------------------------- + + def step_activate_next_unit(self) -> bool: + """检查当前单元是否已完成,若完成则激活下一单元""" + if not self.ctx.unit_id: + return False + + url = f"{self.base_url}/wl/api/study-plan/study-plan" + params = { + "locale": self.locale, + "clientTimezone": self.timezone, + "courseId": self.ctx.course_id, + "levelId": self.ctx.level_id, + "unitId": self.ctx.unit_id, + } + headers = self._learn_headers() + + resp = self.session.get(url, params=params, headers=headers, timeout=REQUEST_TIMEOUT) + resp.raise_for_status() + data = resp.json() + + is_completed = data.get("isUnitCompleted", False) + next_unit_id = data.get("nextUnitId", "") + + if is_completed and next_unit_id: + self._log(f"当前单元已完成,激活下一单元 (nextUnitId={next_unit_id})") + put_resp = self.session.put( + url, params=params, json={"unitId": next_unit_id}, + headers=headers, timeout=REQUEST_TIMEOUT, + ) + put_resp.raise_for_status() + self._log(f"下一单元已激活 (status={put_resp.status_code})") + return True + + return False + # -------------------------------------------------------- # 主流程 # -------------------------------------------------------- @@ -912,6 +950,9 @@ class EFCourseAutopilot: elapsed = time.time() - start_time self._print_summary(total_tasks, elapsed) + # 步骤⑤: 检查并激活下一单元 + self.step_activate_next_unit() + return all(r.success for r in self.results) except requests.exceptions.HTTPError as e: