2023-05-18 15:03:21 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"encoding/json"
|
|
|
|
)
|
|
|
|
|
2023-05-19 15:05:55 +00:00
|
|
|
type PaginationData struct {
|
|
|
|
PreviousPage int
|
|
|
|
CurrentPage int
|
|
|
|
NextPage int
|
|
|
|
}
|
|
|
|
|
2023-05-18 15:03:21 +00:00
|
|
|
type PixivResponse struct {
|
|
|
|
Error bool
|
|
|
|
Message string
|
|
|
|
Body json.RawMessage
|
|
|
|
}
|
|
|
|
|
2023-06-01 09:14:02 +00:00
|
|
|
type RankingResponse struct {
|
|
|
|
Artworks []RankedArtwork `json:"contents"`
|
|
|
|
Mode string `json:"mode"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
}
|
|
|
|
|
2023-05-18 15:03:21 +00:00
|
|
|
type ImageResponse struct {
|
|
|
|
Urls map[string]string `json:"urls"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TagResponse struct {
|
|
|
|
AuthorID string `json:"authorId"`
|
|
|
|
RawTags json.RawMessage `json:"tags"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pixiv returns 0, 1, 2 to filter SFW and/or NSFW artworks.
|
|
|
|
// Those values are saved in `xRestrict`
|
|
|
|
// 0: Safe
|
|
|
|
// 1: R18
|
|
|
|
// 2: R18G
|
|
|
|
type xRestrict int
|
|
|
|
|
|
|
|
const (
|
|
|
|
Safe xRestrict = 0
|
|
|
|
R18 xRestrict = 1
|
|
|
|
R18G xRestrict = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
var xRestrictModel = map[xRestrict]string{
|
2023-05-19 11:17:59 +00:00
|
|
|
Safe: "",
|
2023-05-18 15:03:21 +00:00
|
|
|
R18: "R18",
|
|
|
|
R18G: "R18G",
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pixiv returns 0, 1, 2 to filter SFW and/or NSFW artworks.
|
|
|
|
// Those values are saved in `aiType`
|
|
|
|
// 0: Not rated / Unknown
|
|
|
|
// 1: Not AI-generated
|
|
|
|
// 2: AI-generated
|
|
|
|
|
|
|
|
type aiType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
Unrated aiType = 0
|
|
|
|
NotAI aiType = 1
|
|
|
|
AI aiType = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
var aiTypeModel = map[aiType]string{
|
|
|
|
Unrated: "Unrated",
|
2023-05-19 11:17:59 +00:00
|
|
|
NotAI: "Not AI",
|
2023-05-18 15:03:21 +00:00
|
|
|
AI: "AI",
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pixiv gives us 5 types of an image. I don't need the mini one tho.
|
2023-06-01 09:14:02 +00:00
|
|
|
// PS: Where tf is my 360x360 image, Pixiv?
|
2023-05-18 15:03:21 +00:00
|
|
|
type Image struct {
|
|
|
|
Small string `json:"thumb_mini"`
|
|
|
|
Medium string `json:"small"`
|
|
|
|
Large string `json:"regular"`
|
|
|
|
Original string `json:"original"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Tag struct {
|
|
|
|
Name string `json:"tag"`
|
|
|
|
TranslatedName string `json:"translation"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Illust struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description template.HTML `json:"description"`
|
|
|
|
UserID string `json:"userId"`
|
|
|
|
UserName string `json:"userName"`
|
|
|
|
UserAccount string `json:"userAccount"`
|
|
|
|
Date time.Time `json:"uploadDate"`
|
|
|
|
Images []Image `json:"images"`
|
|
|
|
Tags []Tag `json:"tags"`
|
|
|
|
Pages int `json:"pageCount"`
|
|
|
|
Bookmarks int `json:"bookmarkCount"`
|
|
|
|
Likes int `json:"likeCount"`
|
|
|
|
Comments int `json:"commentCount"`
|
|
|
|
Views int `json:"viewCount"`
|
|
|
|
XRestrict xRestrict `json:"xRestrict"`
|
|
|
|
AiType aiType `json:"aiType"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type IllustShort struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Description template.HTML `json:"description"`
|
|
|
|
ArtistID string `json:"userId"`
|
|
|
|
ArtistName string `json:"userName"`
|
|
|
|
ArtistAvatar string `json:"profileImageUrl"`
|
|
|
|
Date time.Time `json:"uploadDate"`
|
|
|
|
Thumbnail string `json:"url"`
|
|
|
|
Pages int `json:"pageCount"`
|
|
|
|
XRestrict xRestrict `json:"xRestrict"`
|
|
|
|
AiType aiType `json:"aiType"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
ID string `json:"userId"`
|
|
|
|
Name string `json:"name"`
|
2023-05-19 05:15:27 +00:00
|
|
|
Avatar string `json:"imageBig"`
|
2023-05-18 15:03:21 +00:00
|
|
|
BackgroundImage string `json:"background"`
|
|
|
|
Following int `json:"following"`
|
|
|
|
MyPixiv int `json:"mypixivCount"`
|
|
|
|
Comment string `json:"comment"`
|
|
|
|
Artworks []IllustShort `json:"artworks"`
|
2023-05-19 15:05:55 +00:00
|
|
|
ArtworksCount int
|
2023-05-18 15:03:21 +00:00
|
|
|
}
|
2023-06-01 09:14:02 +00:00
|
|
|
|
|
|
|
type RankedArtwork struct {
|
2023-06-01 10:22:20 +00:00
|
|
|
ID int `json:"illust_id"`
|
2023-06-01 09:14:02 +00:00
|
|
|
Title string `json:"title"`
|
2023-06-01 14:36:47 +00:00
|
|
|
Rank int `json:"rank"`
|
2023-06-01 10:22:20 +00:00
|
|
|
Pages string `json:"illust_page_count"`
|
2023-06-01 09:14:02 +00:00
|
|
|
Image string `json:"url"`
|
2023-06-01 10:22:20 +00:00
|
|
|
ArtistID int `json:"user_id"`
|
2023-06-01 09:14:02 +00:00
|
|
|
ArtistName string `json:"user_name"`
|
|
|
|
ArtistAvatar string `json:"profile_img"`
|
|
|
|
}
|
2023-06-02 14:40:42 +00:00
|
|
|
|
|
|
|
type TagDetail struct {
|
|
|
|
Name string `json:"tag"`
|
|
|
|
AlternativeName string `json:"word"`
|
|
|
|
Metadata map[string]string `json:"pixpedia"`
|
|
|
|
}
|