Compare commits

..

No commits in common. "f44c3496f56729df01ad224fdb6385ddb990eab6" and "f642d81f40e3ebf59ceeaf176969792342991d1e" have entirely different histories.

3 changed files with 19 additions and 25 deletions

View File

@ -6,11 +6,10 @@ import (
"path"
"strconv"
"time"
"os"
"github.com/dustin/go-humanize"
"github.com/logrusorgru/aurora"
"github.com/BitHeaven-Official/e6dl/e621"
"github.com/tjhorner/e6dl/e621"
)
// workState stores the state of all the jobs and
@ -121,28 +120,23 @@ 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
}
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
}
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
}
return nil
}

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/BitHeaven-Official/e6dl
module github.com/tjhorner/e6dl
go 1.14

View File

@ -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", 999999999, "Maximum amount of posts to grab from e621")
postLimit := flag.Int("limit", 99999999, "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...", i)
fmt.Printf("Fetching page %d/%d...", i, *pages)
posts, err := e621.GetPostsForTags(*tags, *postLimit, *sfw, i)
if err != nil {