|
|
@@ -10,11 +10,16 @@ proc parseUserResult*(userResult: UserResult): User =
|
|
|
result.verifiedType = blue
|
|
|
|
|
|
if result.username.len == 0 and userResult.core.screenName.len > 0:
|
|
|
+ # Modern UserByRestId/UserByScreenName shape: `legacy` is empty and the data
|
|
|
+ # lives in typed sub-objects (core/relationship_counts/tweet_counts/etc.).
|
|
|
result.id = userResult.restId
|
|
|
result.username = userResult.core.screenName
|
|
|
result.fullname = userResult.core.name
|
|
|
result.userPic = userResult.avatar.imageUrl.replace("_normal", "")
|
|
|
|
|
|
+ if userResult.banner.imageUrl.len > 0:
|
|
|
+ result.banner = userResult.banner.imageUrl & "/1500x500"
|
|
|
+
|
|
|
if userResult.privacy.isSome:
|
|
|
result.protected = userResult.privacy.get.protected
|
|
|
|
|
|
@@ -29,8 +34,23 @@ proc parseUserResult*(userResult: UserResult): User =
|
|
|
if v.verifiedType != VerifiedType.none:
|
|
|
result.verifiedType = v.verifiedType
|
|
|
|
|
|
- if userResult.profileBio.isSome and result.bio.len == 0:
|
|
|
- result.bio = userResult.profileBio.get.description
|
|
|
+ if userResult.relationshipCounts.isSome:
|
|
|
+ let rc = userResult.relationshipCounts.get
|
|
|
+ result.followers = rc.followers
|
|
|
+ result.following = rc.following
|
|
|
+
|
|
|
+ if userResult.tweetCounts.isSome:
|
|
|
+ let tc = userResult.tweetCounts.get
|
|
|
+ result.tweets = tc.tweets
|
|
|
+ result.media = tc.mediaTweets
|
|
|
+
|
|
|
+ if userResult.actionCounts.isSome:
|
|
|
+ result.likes = userResult.actionCounts.get.favoritesCount
|
|
|
+
|
|
|
+ if userResult.profileBio.isSome:
|
|
|
+ let bio = userResult.profileBio.get
|
|
|
+ result.bio = bio.description
|
|
|
+ result.expandUserEntities(bio.entities)
|
|
|
|
|
|
proc parseGraphUser*(json: string): User =
|
|
|
if json.len == 0 or json[0] != '{':
|