removed download limit added simple mode for logfile
All checks were successful
Build this app / Builder (push) Successful in 40s
All checks were successful
Build this app / Builder (push) Successful in 40s
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
name: Build this app
|
name: Build this app
|
||||||
run-name: ${{ gitea.actor }} is building GOMAD 🚀
|
run-name: ${{ gitea.actor }} is building GOMAD 🚀
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
tags: ['v*']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Builder:
|
Builder:
|
||||||
|
|||||||
20
main.go
20
main.go
@@ -16,6 +16,8 @@ import (
|
|||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var simplePtr *bool
|
||||||
|
|
||||||
type pageInfo struct {
|
type pageInfo struct {
|
||||||
StatusCode int
|
StatusCode int
|
||||||
Links map[string]int
|
Links map[string]int
|
||||||
@@ -135,6 +137,7 @@ func downloadChapter(chapterPath string, url string) {
|
|||||||
c.OnHTML("section", func(h *colly.HTMLElement) {
|
c.OnHTML("section", func(h *colly.HTMLElement) {
|
||||||
images := h.DOM.Find("img")
|
images := h.DOM.Find("img")
|
||||||
imagesLength := images.Length()
|
imagesLength := images.Length()
|
||||||
|
|
||||||
bar := progressbar.NewOptions(imagesLength,
|
bar := progressbar.NewOptions(imagesLength,
|
||||||
progressbar.OptionEnableColorCodes(true),
|
progressbar.OptionEnableColorCodes(true),
|
||||||
progressbar.OptionFullWidth(),
|
progressbar.OptionFullWidth(),
|
||||||
@@ -149,7 +152,9 @@ func downloadChapter(chapterPath string, url string) {
|
|||||||
}))
|
}))
|
||||||
images.Each(func(i int, s *goquery.Selection) {
|
images.Each(func(i int, s *goquery.Selection) {
|
||||||
imgSrc, _ := s.Attr("src")
|
imgSrc, _ := s.Attr("src")
|
||||||
bar.Add(1)
|
if !*simplePtr {
|
||||||
|
bar.Add(1)
|
||||||
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
count++
|
count++
|
||||||
go downloadImage(imgSrc, chapterPath+"/")
|
go downloadImage(imgSrc, chapterPath+"/")
|
||||||
@@ -196,7 +201,9 @@ func compressToCbz(chapterPath string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
bar.Add(1)
|
if !*simplePtr {
|
||||||
|
bar.Add(1)
|
||||||
|
}
|
||||||
defer f1.Close()
|
defer f1.Close()
|
||||||
|
|
||||||
w1, err := zipWriter.Create(e.Name())
|
w1, err := zipWriter.Create(e.Name())
|
||||||
@@ -230,7 +237,7 @@ func downloadSeries(url string, downloadPath string, single float64) {
|
|||||||
|
|
||||||
log.Println("Starting to download", seriesName)
|
log.Println("Starting to download", seriesName)
|
||||||
downloadCount := 0
|
downloadCount := 0
|
||||||
for i, c := range s.Chapters {
|
for _, c := range s.Chapters {
|
||||||
chapterPath := fmt.Sprintf("%s/%s", seriesPath, c.Name)
|
chapterPath := fmt.Sprintf("%s/%s", seriesPath, c.Name)
|
||||||
if _, err := os.Stat(seriesPath + "/" + c.Name + ".cbz"); os.IsNotExist(err) {
|
if _, err := os.Stat(seriesPath + "/" + c.Name + ".cbz"); os.IsNotExist(err) {
|
||||||
log.Println("Downloading ", c.Name)
|
log.Println("Downloading ", c.Name)
|
||||||
@@ -242,9 +249,9 @@ func downloadSeries(url string, downloadPath string, single float64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if after 5 five files no download has happened just move on to the next
|
// if after 5 five files no download has happened just move on to the next
|
||||||
if i == 5 && downloadCount < 6 {
|
//if i == 5 && downloadCount < 6 {
|
||||||
break
|
// break
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
if downloadCount == 0 {
|
if downloadCount == 0 {
|
||||||
@@ -257,6 +264,7 @@ func main() {
|
|||||||
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")
|
chapterPtr := flag.Float64("c", 9999, "Specific chapter")
|
||||||
|
simplePtr = flag.Bool("s", false, "Simple output for readable logs")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *urlPtr == "" && *filePtr == "" {
|
if *urlPtr == "" && *filePtr == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user