added wonky single chapter impport
All checks were successful
Build this app / Builder (push) Successful in 38s
All checks were successful
Build this app / Builder (push) Successful in 38s
This commit is contained in:
33
main.go
33
main.go
@@ -62,7 +62,7 @@ func FormatChapterString(s string) string {
|
|||||||
return intPart + "." + parts[1]
|
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)
|
url := fmt.Sprintf("https://weebcentral.com/series/%s/full-chapter-list", seriesID)
|
||||||
|
|
||||||
c := colly.NewCollector()
|
c := colly.NewCollector()
|
||||||
@@ -71,7 +71,6 @@ func getAllChapters(seriesID string) []chapter {
|
|||||||
|
|
||||||
chapt := []chapter{}
|
chapt := []chapter{}
|
||||||
|
|
||||||
count := 0
|
|
||||||
// count links
|
// count links
|
||||||
c.OnHTML("div", func(e *colly.HTMLElement) {
|
c.OnHTML("div", func(e *colly.HTMLElement) {
|
||||||
|
|
||||||
@@ -79,11 +78,21 @@ func getAllChapters(seriesID string) []chapter {
|
|||||||
link, _ := h.Attr("href")
|
link, _ := h.Attr("href")
|
||||||
name := strings.Split(h.Find("span span").First().Text(), " ")[1]
|
name := strings.Split(h.Find("span span").First().Text(), " ")[1]
|
||||||
chNum := FormatChapterString(name)
|
chNum := FormatChapterString(name)
|
||||||
chapt = append(chapt, chapter{
|
|
||||||
Name: "Chapter " + chNum,
|
if single != 9999 {
|
||||||
Link: link,
|
if name == fmt.Sprintf("%g", single) {
|
||||||
})
|
chapt = append(chapt, chapter{
|
||||||
count++
|
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()
|
zipWriter.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadSeries(url string, downloadPath string) {
|
func downloadSeries(url string, downloadPath string, single float64) {
|
||||||
log.Println("Downloading from", url)
|
log.Println("Downloading from", url)
|
||||||
|
|
||||||
seriesID, seriesName := extractSeriesInfo(url)
|
seriesID, seriesName := extractSeriesInfo(url)
|
||||||
@@ -211,7 +220,8 @@ func downloadSeries(url string, downloadPath string) {
|
|||||||
s := series{}
|
s := series{}
|
||||||
|
|
||||||
s.Name = seriesName
|
s.Name = seriesName
|
||||||
s.Chapters = getAllChapters(seriesID)
|
s.Chapters = getAllChapters(seriesID, single)
|
||||||
|
|
||||||
log.Printf("Found %d Chapters\n", len(s.Chapters))
|
log.Printf("Found %d Chapters\n", len(s.Chapters))
|
||||||
|
|
||||||
seriesPath := fmt.Sprintf("%s%s", downloadPath, seriesName)
|
seriesPath := fmt.Sprintf("%s%s", downloadPath, seriesName)
|
||||||
@@ -246,6 +256,7 @@ func main() {
|
|||||||
urlPtr := flag.String("url", "", "WeebCentral URL")
|
urlPtr := flag.String("url", "", "WeebCentral URL")
|
||||||
dlPathPtr := flag.String("path", "", "Download Path")
|
dlPathPtr := flag.String("path", "", "Download Path")
|
||||||
filePtr := flag.String("file", "", "Path to file for multi download")
|
filePtr := flag.String("file", "", "Path to file for multi download")
|
||||||
|
chapterPtr := flag.Float64("c", 9999, "Specific chapter")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *urlPtr == "" && *filePtr == "" {
|
if *urlPtr == "" && *filePtr == "" {
|
||||||
@@ -265,10 +276,10 @@ func main() {
|
|||||||
paths := strings.Split(strings.TrimRight(string(dat), "\n"), "\n")
|
paths := strings.Split(strings.TrimRight(string(dat), "\n"), "\n")
|
||||||
|
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
downloadSeries(p, *dlPathPtr)
|
downloadSeries(p, *dlPathPtr, *chapterPtr)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadSeries(*urlPtr, *dlPathPtr)
|
downloadSeries(*urlPtr, *dlPathPtr, *chapterPtr)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user