增加重复课程学习重试逻辑
This commit is contained in:
+27
-5
@@ -113,21 +113,43 @@ token.txt 说明:
|
||||
verify_ssl=args.verify_ssl,
|
||||
)
|
||||
|
||||
try:
|
||||
success = autopilot.run()
|
||||
max_retries = 3
|
||||
for attempt in range(max_retries + 1):
|
||||
try:
|
||||
success = autopilot.run()
|
||||
except Exception as e:
|
||||
print(f"\n❌ 课程执行异常: {e}")
|
||||
if attempt < max_retries:
|
||||
print(f" 第 {attempt + 1}/{max_retries} 次重试...\n")
|
||||
autopilot = EFCourseAutopilot(
|
||||
token=token,
|
||||
skip_on_fail=True,
|
||||
verify_ssl=args.verify_ssl,
|
||||
)
|
||||
continue
|
||||
total_fail += 1
|
||||
break
|
||||
|
||||
if autopilot.repeat_detected:
|
||||
if attempt < max_retries:
|
||||
print(f"\n⚠️ 检测到重复,第 {attempt + 1}/{max_retries} 次重试...\n")
|
||||
autopilot = EFCourseAutopilot(
|
||||
token=token,
|
||||
skip_on_fail=True,
|
||||
verify_ssl=args.verify_ssl,
|
||||
)
|
||||
continue
|
||||
print("\n⚠️ 检测到重复课程,自动循环终止。")
|
||||
print(f" 「{random.choice(QUOTES)}」 —— 凯特莎")
|
||||
print(" 请手动完成此课程,完成后重新运行本程序继续后续课程。")
|
||||
total_fail += 1
|
||||
break
|
||||
|
||||
if success:
|
||||
total_success += 1
|
||||
else:
|
||||
total_fail += 1
|
||||
except Exception as e:
|
||||
print(f"\n❌ 课程执行异常: {e}")
|
||||
total_fail += 1
|
||||
break
|
||||
|
||||
elapsed = time.time() - start_time
|
||||
print(f"\n{'#' * 60}")
|
||||
|
||||
Reference in New Issue
Block a user