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

View file

@ -47,6 +47,21 @@ func (result *result) parse() *Tweet {
return tw
}
type userResult struct {
Typename string `json:"__typename"`
ID string `json:"id"`
RestID string `json:"rest_id"`
AffiliatesHighlightedLabel struct{} `json:"affiliates_highlighted_label"`
HasGraduatedAccess bool `json:"has_graduated_access"`
IsBlueVerified bool `json:"is_blue_verified"`
ProfileImageShape string `json:"profile_image_shape"`
Legacy legacyUserV2 `json:"legacy"`
}
func (result *userResult) parse() Profile {
return parseProfileV2(*result)
}
type entry struct {
Content struct {
CursorType string `json:"cursorType"`
@ -68,10 +83,7 @@ type entry struct {
} `json:"tweet_results"`
UserDisplayType string `json:"userDisplayType"`
UserResults struct {
Result struct {
RestID string `json:"rest_id"`
Legacy legacyUser `json:"legacy"`
} `json:"result"`
Result userResult `json:"result"`
} `json:"user_results"`
} `json:"itemContent"`
} `json:"content"`
@ -91,6 +103,16 @@ type timelineV2 struct {
} `json:"instructions"`
} `json:"timeline"`
} `json:"timeline_v2"`
Timeline struct {
Timeline struct {
Instructions []struct {
Entries []entry `json:"entries"`
Entry entry `json:"entry"`
Type string `json:"type"`
} `json:"instructions"`
} `json:"timeline"`
} `json:"timeline"`
} `json:"result"`
} `json:"user"`
} `json:"data"`
@ -115,6 +137,24 @@ func (timeline *timelineV2) parseTweets() ([]*Tweet, string) {
return tweets, cursor
}
func (timeline *timelineV2) parseUsers() ([]*Profile, string) {
var cursor string
var users []*Profile
for _, instruction := range timeline.Data.User.Result.Timeline.Timeline.Instructions {
for _, entry := range instruction.Entries {
if entry.Content.CursorType == "Bottom" {
cursor = entry.Content.Value
continue
}
if entry.Content.ItemContent.UserResults.Result.Typename == "User" {
user := entry.Content.ItemContent.UserResults.Result.parse()
users = append(users, &user)
}
}
}
return users, cursor
}
type threadedConversation struct {
Data struct {
ThreadedConversationWithInjectionsV2 struct {