Fix: bad social links type #35
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
4fd3949d1c
commit
41733dbf5c
|
@ -43,6 +43,7 @@ func (p *PixivClient) GetUserArtworksID(id string, category string, page int) (s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the keys, because Pixiv only returns IDs (very evil)
|
// Get the keys, because Pixiv only returns IDs (very evil)
|
||||||
|
|
||||||
if category == "illustrations" || category == "artworks" {
|
if category == "illustrations" || category == "artworks" {
|
||||||
for k := range illusts {
|
for k := range illusts {
|
||||||
ids = append(ids, k)
|
ids = append(ids, k)
|
||||||
|
@ -150,6 +151,7 @@ func (p *PixivClient) GetUserInformation(id string, category string, page int) (
|
||||||
|
|
||||||
user = body.User
|
user = body.User
|
||||||
|
|
||||||
|
|
||||||
if category != "bookmarks" {
|
if category != "bookmarks" {
|
||||||
// Artworks
|
// Artworks
|
||||||
ids, count, err := p.GetUserArtworksID(id, category, page)
|
ids, count, err := p.GetUserArtworksID(id, category, page)
|
||||||
|
@ -185,6 +187,9 @@ func (p *PixivClient) GetUserInformation(id string, category string, page int) (
|
||||||
|
|
||||||
// Public bookmarks count
|
// Public bookmarks count
|
||||||
user.ArtworksCount = count
|
user.ArtworksCount = count
|
||||||
|
|
||||||
|
// Parse social medias
|
||||||
|
user.ParseSocial()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Background image
|
// Background image
|
||||||
|
|
|
@ -166,18 +166,19 @@ type Comment struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID string `json:"userId"`
|
ID string `json:"userId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Avatar string `json:"imageBig"`
|
Avatar string `json:"imageBig"`
|
||||||
BackgroundImage string `json:"background"`
|
BackgroundImage string `json:"background"`
|
||||||
Following int `json:"following"`
|
Following int `json:"following"`
|
||||||
MyPixiv int `json:"mypixivCount"`
|
MyPixiv int `json:"mypixivCount"`
|
||||||
Comment template.HTML `json:"commentHtml"`
|
Comment template.HTML `json:"commentHtml"`
|
||||||
Webpage string `json:"webpage"`
|
Webpage string `json:"webpage"`
|
||||||
Social map[string]map[string]string `json:"social"`
|
SocialRaw json.RawMessage `json:"social"`
|
||||||
Artworks []IllustShort `json:"artworks"`
|
Artworks []IllustShort `json:"artworks"`
|
||||||
ArtworksCount int
|
ArtworksCount int
|
||||||
FrequentTags []FrequentTag
|
FrequentTags []FrequentTag
|
||||||
|
Social map[string]map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *User) ProxyImages(proxy string) {
|
func (s *User) ProxyImages(proxy string) {
|
||||||
|
@ -186,6 +187,15 @@ func (s *User) ProxyImages(proxy string) {
|
||||||
s.Artworks = ProxyShortArtworkSlice(s.Artworks, proxy)
|
s.Artworks = ProxyShortArtworkSlice(s.Artworks, proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *User) ParseSocial() {
|
||||||
|
if string(s.SocialRaw[:]) == "[]" {
|
||||||
|
// Fuck Pixiv
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = json.Unmarshal(s.SocialRaw, &s.Social)
|
||||||
|
}
|
||||||
|
|
||||||
type UserShort struct {
|
type UserShort struct {
|
||||||
ID string `json:"userId"`
|
ID string `json:"userId"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|
Loading…
Reference in a new issue