Skip to content

Commit

Permalink
🐛 修复auto-update配置项读取异常
Browse files Browse the repository at this point in the history
  • Loading branch information
freeok committed Dec 2, 2024
1 parent f79c93e commit 7617f51
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ source-id = 2
download-path = downloads
# 文件扩展名,支持 txt、html、epub,推荐 epub
extname = epub
# 启动时是否自动更新 (true 或 false)
auto-update = true
# 启动时是否自动更新 (1 开,0 关)
auto-update = 1

[crawl]
# 爬取最小间隔 (毫秒)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/pcdd/sonovel/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void main(String[] args) {
// release 前改为 Level.OFF
ConsoleLog.setLevel(Level.OFF);
watchConfig();
if (Boolean.TRUE.equals(config.getAutoUpdate())) {
if (config.getAutoUpdate() == 1) {
new CheckUpdateAction(5000).execute();
}
run();
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/pcdd/sonovel/model/ConfigBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ public class ConfigBean {
private String version;

// base
private int sourceId;
private Integer sourceId;
private String downloadPath;
private String extName;
private Boolean autoUpdate;
private Integer autoUpdate;

// crawl
private int threads;
private int minInterval;
private int maxInterval;
private Integer threads;
private Integer minInterval;
private Integer maxInterval;

// retry
private int maxRetryAttempts;
private int retryMinInterval;
private int retryMaxInterval;
private Integer maxRetryAttempts;
private Integer retryMinInterval;
private Integer retryMaxInterval;

}
2 changes: 1 addition & 1 deletion src/main/java/com/pcdd/sonovel/parse/BookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static String replaceCover(Book book) {

if (book.getBookName().equals(name) && book.getAuthor().equals(author)) {
String coverUrl = e.select(".book-img-box > a > img").attr("src");
return URLUtil.normalize(coverUrl).replaceAll("/.d+(\\.webp)?", "");
return URLUtil.normalize(coverUrl).replaceAll("/150(\\.webp)?", "");
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/pcdd/sonovel/util/ConfigUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public Setting usr() {
public ConfigBean config() {
Props sys = sys();
Setting usr = usr();

ConfigBean configBean = new ConfigBean();
configBean.setVersion(sys.getStr("version"));

configBean.setSourceId(usr.getInt("source-id", SELECTION_1, 1));
configBean.setDownloadPath(usr.getStr("download-path", SELECTION_1, "downloads"));
configBean.setExtName(usr.getStr("extname", SELECTION_1, "epub"));
configBean.setAutoUpdate(usr.getBool("auto-update ", SELECTION_1, true));
configBean.setAutoUpdate(usr.getInt("auto-update", SELECTION_1, 1));

configBean.setThreads(usr.getInt("threads", SELECTION_2, -1));
configBean.setMinInterval(usr.getInt("min", SELECTION_2, 50));
Expand Down

0 comments on commit 7617f51

Please sign in to comment.