diff --git a/profile.go b/profile.go index bba0ee1..e79a92c 100644 --- a/profile.go +++ b/profile.go @@ -50,9 +50,10 @@ type user struct { Data struct { User struct { Result struct { - RestID string `json:"rest_id"` - Legacy legacyUser `json:"legacy"` - Message string `json:"message"` + RestID string `json:"rest_id"` + Legacy legacyUser `json:"legacy"` + Message string `json:"message"` + IsBlueVerified bool `json:"is_blue_verified"` } `json:"result"` } `json:"user"` } `json:"data"` @@ -118,7 +119,9 @@ func (s *Scraper) GetProfile(username string) (Profile, error) { return Profile{}, fmt.Errorf("either @%s does not exist or is private", username) } - return parseProfile(jsn.Data.User.Result.Legacy), nil + profile := parseProfile(jsn.Data.User.Result.Legacy) + profile.IsBlueVerified = jsn.Data.User.Result.IsBlueVerified + return profile, nil } func (s *Scraper) GetProfileByID(userID string) (Profile, error) { @@ -175,7 +178,9 @@ func (s *Scraper) GetProfileByID(userID string) (Profile, error) { return Profile{}, fmt.Errorf("either @%s does not exist or is private", userID) } - return parseProfile(jsn.Data.User.Result.Legacy), nil + profile := parseProfile(jsn.Data.User.Result.Legacy) + profile.IsBlueVerified = jsn.Data.User.Result.IsBlueVerified + return profile, nil } // GetUserIDByScreenName from API diff --git a/util.go b/util.go index c6a4fb8..26264e0 100644 --- a/util.go +++ b/util.go @@ -385,25 +385,28 @@ func parseProfile(user legacyUser) Profile { func parseProfileV2(user userResult) Profile { u := user.Legacy profile := Profile{ - Avatar: u.ProfileImageURLHTTPS, - Banner: u.ProfileBannerURL, - Biography: u.Description, - FollowersCount: u.FollowersCount, - FollowingCount: u.FavouritesCount, - FriendsCount: u.FriendsCount, - IsVerified: u.Verified, - LikesCount: u.FavouritesCount, - ListedCount: u.ListedCount, - Location: u.Location, - Name: u.Name, - PinnedTweetIDs: u.PinnedTweetIdsStr, - TweetsCount: u.StatusesCount, - URL: "https://twitter.com/" + u.ScreenName, - UserID: user.ID, - Username: u.ScreenName, - Sensitive: u.PossiblySensitive, - Following: u.Following, - FollowedBy: u.FollowedBy, + Avatar: u.ProfileImageURLHTTPS, + Banner: u.ProfileBannerURL, + Biography: u.Description, + FollowersCount: u.FollowersCount, + FollowingCount: u.FavouritesCount, + FriendsCount: u.FriendsCount, + IsVerified: u.Verified, + IsBlueVerified: user.IsBlueVerified, + ProfileImageShape: user.ProfileImageShape, + HasGraduatedAccess: user.HasGraduatedAccess, + LikesCount: u.FavouritesCount, + ListedCount: u.ListedCount, + Location: u.Location, + Name: u.Name, + PinnedTweetIDs: u.PinnedTweetIdsStr, + TweetsCount: u.StatusesCount, + URL: "https://twitter.com/" + u.ScreenName, + UserID: user.ID, + Username: u.ScreenName, + Sensitive: u.PossiblySensitive, + Following: u.Following, + FollowedBy: u.FollowedBy, } tm, err := time.Parse(time.RubyDate, u.CreatedAt)