added wonky single chapter impport
All checks were successful
Build this app / Builder (push) Successful in 38s

This commit is contained in:
Itsigo
2026-03-07 18:27:56 +01:00
parent 89ead9d92d
commit 12bc6290ef

33
main.go
View File

@@ -62,7 +62,7 @@ func FormatChapterString(s string) string {
return intPart + "." + parts[1]
}
func getAllChapters(seriesID string) []chapter {
func getAllChapters(seriesID string, single float64) []chapter {
url := fmt.Sprintf("https://weebcentral.com/series/%s/full-chapter-list", seriesID)
c := colly.NewCollector()
@@ -71,7 +71,6 @@ func getAllChapters(seriesID string) []chapter {
chapt := []chapter{}
count := 0
// count links
c.OnHTML("div", func(e *colly.HTMLElement) {
@@ -79,11 +78,21 @@ func getAllChapters(seriesID string) []chapter {
link, _ := h.Attr("href")
name := strings.Split(h.Find("span span").First().Text(), " ")[1]
chNum := FormatChapterString(name)
chapt = append(chapt, chapter{
Name: "Chapter " + chNum,
Link: link,
})
count++
if single != 9999 {
if name == fmt.Sprintf("%g", single) {
chapt = append(chapt, chapter{
Name: "Chapter " + chNum,
Link: link,
})
}
} else {
chapt = append(chapt, chapter{
Name: "Chapter " + chNum,
Link: link,
})
}
})
})
@@ -203,7 +212,7 @@ func compressToCbz(chapterPath string) {
zipWriter.Close()
}
func downloadSeries(url string, downloadPath string) {
func downloadSeries(url string, downloadPath string, single float64) {
log.Println("Downloading from", url)
seriesID, seriesName := extractSeriesInfo(url)
@@ -211,7 +220,8 @@ func downloadSeries(url string, downloadPath string) {
s := series{}
s.Name = seriesName
s.Chapters = getAllChapters(seriesID)
s.Chapters = getAllChapters(seriesID, single)
log.Printf("Found %d Chapters\n", len(s.Chapters))
seriesPath := fmt.Sprintf("%s%s", downloadPath, seriesName)
@@ -246,6 +256,7 @@ func main() {
urlPtr := flag.String("url", "", "WeebCentral URL")
dlPathPtr := flag.String("path", "", "Download Path")
filePtr := flag.String("file", "", "Path to file for multi download")
chapterPtr := flag.Float64("c", 9999, "Specific chapter")
flag.Parse()
if *urlPtr == "" && *filePtr == "" {
@@ -265,10 +276,10 @@ func main() {
paths := strings.Split(strings.TrimRight(string(dat), "\n"), "\n")
for _, p := range paths {
downloadSeries(p, *dlPathPtr)
downloadSeries(p, *dlPathPtr, *chapterPtr)
}
os.Exit(0)
}
downloadSeries(*urlPtr, *dlPathPtr)
downloadSeries(*urlPtr, *dlPathPtr, *chapterPtr)
}