From 5d2c4db0a5efff8e09988b2b7505e075baa4b84d Mon Sep 17 00:00:00 2001 From: grantdfoster Date: Thu, 14 Aug 2025 19:37:22 +0200 Subject: [PATCH] feat: adds profile result type from scraper and json tags for twitter types --- types/twitter.go | 129 +++++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 48 deletions(-) diff --git a/types/twitter.go b/types/twitter.go index cb020e6..e699fbd 100644 --- a/types/twitter.go +++ b/types/twitter.go @@ -4,72 +4,72 @@ package types import "time" type TweetResult struct { - ID int64 `json:"id"` - TweetID string - ConversationID string - UserID string - Text string - CreatedAt time.Time - Timestamp int64 + ID int64 `json:"id"` + TweetID string `json:"tweet_id"` + ConversationID string `json:"conversation_id"` + UserID string `json:"user_id"` + Text string `json:"text"` + CreatedAt time.Time `json:"created_at"` + Timestamp int64 `json:"timestamp"` ThreadCursor struct { - FocalTweetID string - ThreadID string - Cursor string - CursorType string + FocalTweetID string `json:"focal_tweet_id"` + ThreadID string `json:"thread_id"` + Cursor string `json:"cursor"` + CursorType string `json:"cursor_type"` } - IsQuoted bool - IsPin bool - IsReply bool - IsRetweet bool - IsSelfThread bool - Likes int - Hashtags []string - HTML string - Replies int - Retweets int - URLs []string - Username string + IsQuoted bool `json:"is_quoted"` + IsPin bool `json:"is_pin"` + IsReply bool `json:"is_reply"` + IsRetweet bool `json:"is_retweet"` + IsSelfThread bool `json:"is_self_thread"` + Likes int `json:"likes"` + Hashtags []string `json:"hashtags"` + HTML string `json:"html"` + Replies int `json:"replies"` + Retweets int `json:"retweets"` + URLs []string `json:"urls"` + Username string `json:"username"` - Photos []Photo + Photos []Photo `json:"photos"` // Video type. - Videos []Video + Videos []Video `json:"videos"` - RetweetedStatusID string - Views int - SensitiveContent bool + RetweetedStatusID string `json:"retweeted_status_id"` + Views int `json:"views"` + SensitiveContent bool `json:"sensitive_content"` // from twitterx - AuthorID string - PublicMetrics PublicMetrics - PossiblySensitive bool - Lang string - NewestID string - OldestID string - ResultCount int + AuthorID string `json:"author_id"` + PublicMetrics PublicMetrics `json:"public_metrics"` + PossiblySensitive bool `json:"possibly_sensitive"` + Lang string `json:"lang"` + NewestID string `json:"newest_id"` + OldestID string `json:"oldest_id"` + ResultCount int `json:"result_count"` - Error error + Error error `json:"error"` } type PublicMetrics struct { - RetweetCount int - ReplyCount int - LikeCount int - QuoteCount int - BookmarkCount int - ImpressionCount int + RetweetCount int `json:"retweet_count"` + ReplyCount int `json:"reply_count"` + LikeCount int `json:"like_count"` + QuoteCount int `json:"quote_count"` + BookmarkCount int `json:"bookmark_count"` + ImpressionCount int `json:"impression_count"` } type Photo struct { - ID string - URL string + ID string `json:"id"` + URL string `json:"url"` } type Video struct { - ID string - Preview string - URL string - HLSURL string + ID string `json:"id"` + Preview string `json:"preview"` + URL string `json:"url"` + HLSURL string `json:"hls_url"` } type ProfileResultApify struct { @@ -152,3 +152,36 @@ type URLEntity struct { DisplayURL string `json:"display_url"` Indices []int `json:"indices"` } + +type ProfileResultScraper struct { + Avatar string `json:"avatar"` + Banner string `json:"banner"` + Biography string `json:"biography"` + Birthday string `json:"birthday"` + FollowersCount int `json:"followers_count"` + FollowingCount int `json:"following_count"` + FriendsCount int `json:"friends_count"` + IsPrivate bool `json:"is_private"` + IsVerified bool `json:"is_verified"` + IsBlueVerified bool `json:"is_blue_verified"` + Joined *time.Time `json:"joined"` + LikesCount int `json:"likes_count"` + ListedCount int `json:"listed_count"` + Location string `json:"location"` + Name string `json:"name"` + PinnedTweetIDs []string `json:"pinned_tweet_ids"` + TweetsCount int `json:"tweets_count"` + URL string `json:"url"` + UserID string `json:"user_id"` + Username string `json:"username"` + Website string `json:"website"` + Sensitive bool `json:"sensitive"` + Following bool `json:"following"` + FollowedBy bool `json:"followed_by"` + MediaCount int `json:"media_count"` + FastFollowersCount int `json:"fast_followers_count"` + NormalFollowersCount int `json:"normal_followers_count"` + ProfileImageShape string `json:"profile_image_shape"` + HasGraduatedAccess bool `json:"has_graduated_access"` + CanHighlightTweets bool `json:"can_highlight_tweets"` +}