FEAT, list following

This commit is contained in:
Joaco Esteban 2024-02-03 14:53:11 +01:00
parent be3eeb9091
commit c967fdefdd
5 changed files with 189 additions and 6 deletions

35
util.go
View file

@ -342,7 +342,6 @@ func parseProfile(user legacyUser) Profile {
FollowersCount: user.FollowersCount,
FollowingCount: user.FavouritesCount,
FriendsCount: user.FriendsCount,
IsPrivate: user.Protected,
IsVerified: user.Verified,
LikesCount: user.FavouritesCount,
ListedCount: user.ListedCount,
@ -368,6 +367,40 @@ func parseProfile(user legacyUser) Profile {
return 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,
}
tm, err := time.Parse(time.RubyDate, u.CreatedAt)
if err == nil {
tm = tm.UTC()
profile.Joined = &tm
}
if len(u.Entities.URL.Urls) > 0 {
profile.Website = u.Entities.URL.Urls[0].ExpandedURL
}
return profile
}
func mapToJSONString(data map[string]interface{}) string {
jsonBytes, err := json.Marshal(data)
if err != nil {