diff --git a/handler/user.go b/handler/user.go index e28b96a..e2be0e3 100644 --- a/handler/user.go +++ b/handler/user.go @@ -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 diff --git a/models/models.go b/models/models.go index 53c129e..0964c98 100644 --- a/models/models.go +++ b/models/models.go @@ -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"`