diff --git a/cmd/twitter/main.go b/cmd/twitter/main.go index a0526c3..5b23a91 100644 --- a/cmd/twitter/main.go +++ b/cmd/twitter/main.go @@ -285,7 +285,7 @@ func create_profile(target_dir string) { } func _fetch_user_by_id(id scraper.UserID) error { - user, err := api.GetUserByID(id) + user, err := scraper.GetUserByID(id) if errors.Is(err, scraper.ErrDoesntExist) { // Mark them as deleted. // Handle and display name won't be updated if the user exists. diff --git a/pkg/persistence/tweet_trove_queries.go b/pkg/persistence/tweet_trove_queries.go index 98c6a6e..c39806b 100644 --- a/pkg/persistence/tweet_trove_queries.go +++ b/pkg/persistence/tweet_trove_queries.go @@ -22,7 +22,7 @@ func (p Profile) SaveTweetTrove(trove TweetTrove, should_download bool, api *API "Conflicting user handle found (ID %d); old user has been marked deleted. Rescraping them\n", conflict_err.ConflictingUserID, ) - user, err := api.GetUserByID(conflict_err.ConflictingUserID) + user, err := GetUserByID(conflict_err.ConflictingUserID) if errors.Is(err, ErrDoesntExist) { // Mark them as deleted. // Handle and display name won't be updated if the user exists. diff --git a/pkg/scraper/user.go b/pkg/scraper/user.go index 29173ca..c1cdef0 100644 --- a/pkg/scraper/user.go +++ b/pkg/scraper/user.go @@ -173,6 +173,15 @@ func ParseSingleUser(apiUser APIUser) (ret User, err error) { return } +// Calls API#GetUserByID and returns the parsed result +func GetUserByID(u_id UserID) (User, error) { + session, err := NewGuestSession() // This endpoint works better if you're not logged in + if err != nil { + return User{}, err + } + return session.GetUserByID(u_id) +} + /** * Make a filename for the profile image, that hopefully won't clobber other ones */