Compare commits
10 Commits
f642d81f40
...
f44c3496f5
Author | SHA1 | Date |
---|---|---|
BitHeaven | f44c3496f5 | |
BitHeaven | fc4665fdfb | |
BitHeaven | ae19866d59 | |
BitHeaven | 4088e2baf1 | |
BitHeaven | 0707246c77 | |
BitHeaven | 6c5c181a96 | |
BitHeaven | 3a3b768042 | |
BitHeaven | 355df543d3 | |
BitHeaven | d4d05cfb76 | |
BitHeaven | fedb967ec6 |
|
@ -6,10 +6,11 @@ import (
|
|||
"path"
|
||||
"strconv"
|
||||
"time"
|
||||
"os"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/logrusorgru/aurora"
|
||||
"github.com/tjhorner/e6dl/e621"
|
||||
"github.com/BitHeaven-Official/e6dl/e621"
|
||||
)
|
||||
|
||||
// workState stores the state of all the jobs and
|
||||
|
@ -120,23 +121,28 @@ func getSavePath(post *e621.Post, directory *string) string {
|
|||
|
||||
func downloadPost(post *e621.Post, directory string) error {
|
||||
savePath := getSavePath(post, &directory)
|
||||
|
||||
if _, err := os.Stat(savePath); err == nil {
|
||||
fmt.Print("File exists, skip...\n")
|
||||
} else {
|
||||
resp, err := e621.HTTPGet(post.File.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := e621.HTTPGet(post.File.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(savePath, body, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(savePath, body, 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module github.com/tjhorner/e6dl
|
||||
module github.com/BitHeaven-Official/e6dl
|
||||
|
||||
go 1.14
|
||||
|
||||
|
|
4
main.go
4
main.go
|
@ -14,7 +14,7 @@ func main() {
|
|||
// define cmd line flags
|
||||
tags := flag.String("tags", "", "Tags to search for")
|
||||
maxConcurrents := flag.Int("concurrents", 5, "Maximum amount of concurrent downloads")
|
||||
postLimit := flag.Int("limit", 99999999, "Maximum amount of posts to grab from e621")
|
||||
postLimit := flag.Int("limit", 999999999, "Maximum amount of posts to grab from e621")
|
||||
saveDirectory := flag.String("out", "e621", "The directory to write the downloaded posts to")
|
||||
sfw := flag.Bool("sfw", false, "Download posts from e926 instead of e621")
|
||||
|
||||
|
@ -26,7 +26,7 @@ func main() {
|
|||
|
||||
i := 1
|
||||
for {
|
||||
fmt.Printf("Fetching page %d/%d...", i, *pages)
|
||||
fmt.Printf("Fetching page %d...", i)
|
||||
|
||||
posts, err := e621.GetPostsForTags(*tags, *postLimit, *sfw, i)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue