添加了“智慧树”平台中b站网页浏览任务;

调整了对于`UnknownTaskPointException`的处理逻辑;
添加了视频任务的自动取消暂停功能
This commit is contained in:
2025-04-07 13:19:48 +08:00
parent 37edb0d630
commit 9670e6863c

View File

@@ -51,9 +51,9 @@ public class ZhsTask {
log.info("处理第{}个任务点", count.get());
switch (v) {
case "icon-box video" -> handleVideoTask(k);
case "icon-box baidu" -> handleWebTask(k);
case "icon-box baidu", "icon-box bzhan" -> handleWebTask(k);
case "icon-box book", "icon-box other", "icon-box img" -> handleDocTask(k);
default -> throw new UnknownTaskPointException("未设置处理策略的任务点类型!");
default -> throw new UnknownTaskPointException("未设置处理策略的任务点类型: " + v);
}
}
driver.findElement(By.xpath("//img[@alt='back']")).click();
@@ -62,13 +62,17 @@ public class ZhsTask {
log.info("任务完成!");
driver.quit();
break;
}catch (WebDriverException e) {
} catch (WebDriverException e) {
log.error("\r\n---------------\r\n");
log.error(e.getLocalizedMessage());
log.error("\r\n---------------\r\n");
log.error("Something went wrong, will retry later..");
driver.get("https://onlineweb.zhihuishu.com/onlinestuh5");
Thread.sleep(5000);
} catch (UnknownTaskPointException e) {
log.error(e.getLocalizedMessage());
driver.quit();
break;
}
}
}
@@ -104,7 +108,8 @@ public class ZhsTask {
//开启倍速
try {
driver.findElement(By.xpath("//div[@class='speedTab speedTab15']")).click();
}catch (Exception ignored) {}
} catch (Exception ignored) {
}
String currentTime = "00:00:00";
String duration = "00:00:00";
while (true) {
@@ -115,10 +120,15 @@ public class ZhsTask {
try {
currentTime = driver.findElement(By.xpath(".//span[@class='currentTime']")).getText();
duration = driver.findElement(By.xpath(".//span[@class='duration']")).getText();
}catch (Exception ignored) {}
WebElement playButton = driver.findElement(By.xpath("//div[@id='playButton']"));
if (playButton.getDomAttribute("class").equals("playButton")) {
playButton.click();
}
} catch (Exception ignored) {
}
if (currentTime.equals("00:00:00")) {
continue;
}else {
} else {
log.info("{}/{}", currentTime, duration);
}
if (currentTime.equals(duration)) {