From 375a5ad681e5566be166794cef2fce67ed56d4bc Mon Sep 17 00:00:00 2001 From: TJ Horner Date: Wed, 13 Mar 2019 13:10:05 -0700 Subject: [PATCH] did things --- concurrent/download.go | 6 +---- e621/e621.go | 58 +++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/concurrent/download.go b/concurrent/download.go index 6c25b17..26cfa50 100644 --- a/concurrent/download.go +++ b/concurrent/download.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "path" "strconv" - "strings" "sync" "time" @@ -78,10 +77,7 @@ func work(wn int, posts []e621.Post, directory string, completed *int, successes } func getSavePath(post *e621.Post, directory *string) string { - pathSliced := strings.Split(post.FileURL, ".") - extension := pathSliced[len(pathSliced)-1] - - savePath := path.Join(*directory, strconv.Itoa(post.ID)+"."+extension) + savePath := path.Join(*directory, strconv.Itoa(post.ID)+"."+post.FileExt) return savePath } diff --git a/e621/e621.go b/e621/e621.go index df71fc1..bdccac2 100644 --- a/e621/e621.go +++ b/e621/e621.go @@ -9,35 +9,35 @@ import ( // Post represents an e621 post object returned by the e621 API. type Post struct { - ID int `json:"id"` - Tags string `json:"tags"` - LockedTags bool `json:"locked_tags"` - Description string `json:"description"` - CreatedAt SerializedDate `json:"created_at"` - CreatorID int `json:"creator_id"` - Author string `json:"author"` - Change int `json:"change"` - Source string `json:"source"` - Score int `json:"score"` - FavoritesCount int `json:"fav_count"` - MD5Hash string `json:"md5"` - FileSize int `json:"file_size"` - FileURL string `json:"file_url"` - FileExt string `json:"file_ext"` - PreviewURL string `json:"preview_url"` - PreviewHeight int `json:"preview_height"` - PreviewWidth int `json:"preview_width"` - Rating string `json:"rating"` - Status string `json:"status"` - Width int `json:"width"` - Height int `json:"height"` - HasComments bool `json:"has_comments"` - HasNotes bool `json:"has_notes"` - HasChildren bool `json:"has_children"` - Children string `json:"children"` - ParentID int `json:"parent_id"` - Artist []string `json:"artist"` - Sources []string `json:"sources"` + ID int `json:"id"` // The ID of the post + Tags string `json:"tags"` // Space-separated list of tags attached to this post + LockedTags bool `json:"locked_tags"` // (undocumented) + Description string `json:"description"` // The post's description + CreatedAt SerializedDate `json:"created_at"` // When the post was uploaded + CreatorID int `json:"creator_id"` // User ID of the user who uploaded the post + Author string `json:"author"` // Username of the user who uploaded the post + Change int `json:"change"` // (undocumented) + Source string `json:"source"` // URL that the source for this post can be found at + Score int `json:"score"` // The post's score (upvotes - downvotes) + FavoritesCount int `json:"fav_count"` // Amount of users that favorited this post + MD5Hash string `json:"md5"` // MD5-sum of the post's file's content + FileSize int `json:"file_size"` // Size of the post's file + FileURL string `json:"file_url"` // URL to the full-sized file + FileExt string `json:"file_ext"` // File extension + PreviewURL string `json:"preview_url"` // URL to preview-sized version of the file + PreviewHeight int `json:"preview_height"` // Height of the preview + PreviewWidth int `json:"preview_width"` // Width of the preview + Rating string `json:"rating"` // Rating of the file ("safe", "questionable", "explicit") + Status string `json:"status"` // Moderation status ("active" or "pending") + Width int `json:"width"` // Width of the original file + Height int `json:"height"` // Height of the original file + HasComments bool `json:"has_comments"` // True if post has comments + HasNotes bool `json:"has_notes"` // True if post has notes + HasChildren bool `json:"has_children"` // True if post has children + Children string `json:"children"` // Comma-separated list of children post IDs + ParentID int `json:"parent_id"` // ID of the parent post + Artist []string `json:"artist"` // Slice of artist names + Sources []string `json:"sources"` // Slice of source URLs } // SerializedDate represents a serialized date passed via JSON