Compare commits

...

2 Commits
v0.0.5 ... main

Author SHA1 Message Date
c9a7853cef fix font error 2025-04-21 14:59:51 +10:00
b2130f60d5 fix missing images 2025-04-20 21:44:28 +10:00
2 changed files with 13 additions and 6 deletions

10
.vscode/launch.json vendored
View File

@ -2,12 +2,20 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug download volume",
"name": "volume",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["download", "volume", "-n", "2013", "-v", "165880"]
},
{
"name": "novel",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["download", "novel", "-n", "4325"]
}
]
}

View File

@ -413,7 +413,9 @@ func downloadChapterByPage(page, chapterIdx int, chapter *model.Chapter, outputP
content.Find(".cgo").Remove()
content.Find("center").Remove()
content.Find(".google-auto-placed").Remove()
content.Find("p").Last().AddClass("read-font")
if strings.Contains(resp.String(), `font-family: "read"`) {
content.Find("p").Last().AddClass("read-font")
}
content.Find("img").Each(func(i int, s *goquery.Selection) {
if err != nil {
@ -427,15 +429,12 @@ func downloadChapterByPage(page, chapterIdx int, chapter *model.Chapter, outputP
}
}
fileName := filepath.Join(imgSavePath, fmt.Sprintf("%03v%s", i+1, path.Ext(imgUrl)))
fileName := filepath.Join(imgSavePath, fmt.Sprintf("%03v%s", len(chapter.ImageFullPaths)+1, path.Ext(imgUrl)))
err = DownloadImg(imgUrl, filepath.Join(outputPath, fileName))
if err == nil {
s.SetAttr("src", "../"+strings.TrimPrefix(fileName, "OEBPS/"))
s.RemoveAttr("class")
s.RemoveAttr("data-src")
if s.AttrOr("alt", "") == "" {
s.SetAttr("alt", fmt.Sprintf("image-%03d", i+1))
}
chapter.ImageFullPaths = append(chapter.ImageFullPaths, filepath.Join(outputPath, fileName))
chapter.ImageOEBPSPaths = append(chapter.ImageOEBPSPaths, strings.TrimPrefix(fileName, "OEBPS/"))
}