pixiv-scrapper/pixiv/types.go

130 lines
3.3 KiB
Go

package pixiv
import "fmt"
//Illust .
type Illust struct {
complited bool
ID string `json:"id"`
IlustID string `json:"illustId"`
Title string `json:"title"`
IllustTitle string `json:"illustTitle"`
IllustComment string `json:"illustComment"`
IllustType int `json:"illustType"`
XRestrict int `json:"xRestrict"`
Sl int `json:"sl"`
URLoriginal string `json:"url"`
Pages []IllustPage
URLs struct {
Mini string `json:"mini"`
Thumb string `json:"thumb"`
Small string `json:"small"`
Regular string `json:"regular"`
Original string `json:"original"`
} `json:"urls"`
Description string `json:"description"`
TagsOriginal struct {
AuthorID string `json:"authorId"`
IsLocked bool `json:"isLocked"`
Tags []IllustTag `json:"tags"`
Writable bool `json:"writable"`
} `json:"tags,omitempty"`
stringTags []string
UserID string `json:"userId"`
UserName string `json:"userName"`
UserAccount string `json:"userAccount"`
Width int `json:"width"`
Height int `json:"height"`
PageCount int `json:"pageCount"`
IsBookmarkable bool `json:"isBookmarkable"`
Alt string `json:"alt"`
IsAdContainer bool `json:"isAdContainer"`
TitleCaptionTranslation struct {
WorkTitle string `json:"workTitle"`
WorkCaption string `json:"workCaption"`
} `json:"titleCaptionTranslation"`
CreateDate string `json:"createDate"`
UpdateDate string `json:"updateDate"`
IsUnlisted bool `json:"isUnlisted"`
ProfileImageURL string `json:"profileImageUrl"`
}
// TagsString returns tags in one string separated by "," character
func (i *Illust) TagsString() (r string) {
for _, tag := range i.stringTags {
r = fmt.Sprintf("%s,%s", r, tag)
}
return
}
func (i *Illust) Name() string {
return i.IllustTitle
}
func (i *Illust) Author() string {
return i.UserName
}
func (i *Illust) Comment() string {
return i.IllustComment
}
func (i *Illust) Tags() []string {
return i.stringTags
}
func (i *Illust) Files() (urls []string) {
if len(i.Pages) > 0 {
for _, page := range i.Pages {
urls = append(urls, page.URLs.Original)
}
} else {
urls = append(urls, i.URLs.Original)
}
return
}
func (i *Illust) URL() string {
return i.URLoriginal
}
func (i *Illust) Type() string {
return "pixiv"
}
//IllustTag .
type IllustTag struct {
Tag string `json:"tag"`
Locked bool `json:"locked"`
Deletable bool `json:"deletable"`
UserID string `json:"userId"`
UserName string `json:"userName"`
Romaji string `json:"romaji"`
Translation struct {
En string `json:"en"`
} `json:"translation"`
}
//IllustPage .
type IllustPage struct {
URLs struct {
Mini string `json:"mini"`
Thumb string `json:"thumb"`
Small string `json:"small"`
Regular string `json:"regular"`
Original string `json:"original"`
} `json:"urls"`
Width int `json:"width"`
Height int `json:"height"`
}
//User .
type User struct {
UserID string `json:"userId"`
UserName string `json:"userName"`
ProfileImageURL string `json:"profileImageUrl"`
Following bool `json:"following"`
Followed bool `json:"followed"`
illusts []Illust
}