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)
|
||||
|
||||
if category == "illustrations" || category == "artworks" {
|
||||
for k := range illusts {
|
||||
ids = append(ids, k)
|
||||
|
@ -150,6 +151,7 @@ func (p *PixivClient) GetUserInformation(id string, category string, page int) (
|
|||
|
||||
user = body.User
|
||||
|
||||
|
||||
if category != "bookmarks" {
|
||||
// Artworks
|
||||
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
|
||||
user.ArtworksCount = count
|
||||
|
||||
// Parse social medias
|
||||
user.ParseSocial()
|
||||
}
|
||||
|
||||
// Background image
|
||||
|
|
|
@ -166,18 +166,19 @@ type Comment struct {
|
|||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"userId"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"imageBig"`
|
||||
BackgroundImage string `json:"background"`
|
||||
Following int `json:"following"`
|
||||
MyPixiv int `json:"mypixivCount"`
|
||||
Comment template.HTML `json:"commentHtml"`
|
||||
Webpage string `json:"webpage"`
|
||||
Social map[string]map[string]string `json:"social"`
|
||||
Artworks []IllustShort `json:"artworks"`
|
||||
ID string `json:"userId"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"imageBig"`
|
||||
BackgroundImage string `json:"background"`
|
||||
Following int `json:"following"`
|
||||
MyPixiv int `json:"mypixivCount"`
|
||||
Comment template.HTML `json:"commentHtml"`
|
||||
Webpage string `json:"webpage"`
|
||||
SocialRaw json.RawMessage `json:"social"`
|
||||
Artworks []IllustShort `json:"artworks"`
|
||||
ArtworksCount int
|
||||
FrequentTags []FrequentTag
|
||||
Social map[string]map[string]string
|
||||
}
|
||||
|
||||
func (s *User) ProxyImages(proxy string) {
|
||||
|
@ -186,6 +187,15 @@ func (s *User) ProxyImages(proxy string) {
|
|||
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 {
|
||||
ID string `json:"userId"`
|
||||
Name string `json:"name"`
|
||||
|
|
Loading…
Reference in a new issue