mirror of
https://github.com/bestnite/bilinovel-downloader.git
synced 2026-07-25 20:21:56 +00:00
fix: remove EPUB ad gaps and preserve chapter titles
This commit is contained in:
@@ -266,8 +266,7 @@ func (b *Bilinovel) GetVolume(novelId int, volumeId int, skipChapterContent bool
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get chapter: %v", err)
|
||||
}
|
||||
chapter.Id = chapterId
|
||||
volume.Chapters[i] = chapter
|
||||
volume.Chapters[i] = mergeDownloadedChapter(volume.Chapters[i], chapter)
|
||||
} else {
|
||||
return nil, fmt.Errorf("failed to get chapter id: %v", volume.Chapters[i].Url)
|
||||
}
|
||||
@@ -277,6 +276,12 @@ func (b *Bilinovel) GetVolume(novelId int, volumeId int, skipChapterContent bool
|
||||
return volume, nil
|
||||
}
|
||||
|
||||
func mergeDownloadedChapter(listedChapter, downloadedChapter *model.Chapter) *model.Chapter {
|
||||
downloadedChapter.Title = listedChapter.Title
|
||||
downloadedChapter.Url = listedChapter.Url
|
||||
return downloadedChapter
|
||||
}
|
||||
|
||||
func (b *Bilinovel) getAllVolumes(novelId int, skipChapterContent bool, skipVolumes []int) ([]*model.Volume, error) {
|
||||
b.logger.Info("Getting all volumes of novel", slog.Int("novelId", novelId))
|
||||
|
||||
@@ -442,9 +447,7 @@ func (b *Bilinovel) getChapterByPage(pwPage playwright.Page, chapter *model.Chap
|
||||
chapter.Title = doc.Find("#atitle").Text()
|
||||
}
|
||||
content := doc.Find("#acontent").First()
|
||||
content.Find(".cgo").Remove()
|
||||
content.Find("center").Remove()
|
||||
content.Find(".google-auto-placed").Remove()
|
||||
cleanChapterContent(content)
|
||||
|
||||
if strings.Contains(resortedHtml, `font-family: "read"`) {
|
||||
html, err := content.Find("p").Last().Html()
|
||||
@@ -518,6 +521,11 @@ func (b *Bilinovel) getChapterByPage(pwPage playwright.Page, chapter *model.Chap
|
||||
return hasNext, nil
|
||||
}
|
||||
|
||||
func cleanChapterContent(content *goquery.Selection) {
|
||||
content.Find(".cgo, .csgo, .co, .google-auto-placed, ins.adsbygoogle").Remove()
|
||||
content.Find("center").Remove()
|
||||
}
|
||||
|
||||
func (b *Bilinovel) getImg(url string) ([]byte, error) {
|
||||
b.logger.Info("Getting img", slog.String("url", url))
|
||||
resp, err := b.restyClient.R().SetHeader("Referer", "https://www.bilinovel.com").Get(url)
|
||||
|
||||
Reference in New Issue
Block a user