46 lines
991 B
Go
Raw Normal View History

2021-11-06 14:55:15 -07:00
package scraper
2022-03-06 19:27:30 -08:00
import (
"errors"
2022-11-13 12:04:25 -05:00
"fmt"
2022-03-06 19:27:30 -08:00
)
2021-11-06 14:55:15 -07:00
func TimestampToDateString(timestamp int) string {
2022-03-13 17:09:43 -07:00
panic("???") // TODO
2021-11-06 14:55:15 -07:00
}
/**
* TODO: Search modes:
* - regular ("top")
* - latest / "live"
* - search for users
* - photos
* - videos
*/
func Search(query string, min_results int) (trove TweetTrove, err error) {
2023-02-17 13:07:12 -05:00
tweet_response, err := the_api.Search(query, "")
2021-11-06 14:55:15 -07:00
if err != nil {
return
}
if len(tweet_response.GlobalObjects.Tweets) < min_results && tweet_response.GetCursor() != "" {
2023-02-17 13:07:12 -05:00
err = the_api.GetMoreTweetsFromSearch(query, &tweet_response, min_results)
2022-03-06 19:27:30 -08:00
if errors.Is(err, END_OF_FEED) {
2021-11-06 14:55:15 -07:00
println("End of feed!")
2022-03-06 19:27:30 -08:00
} else if err != nil {
2021-11-06 14:55:15 -07:00
return
}
}
trove, err = tweet_response.ToTweetTrove()
2022-11-13 12:04:25 -05:00
if err != nil {
err = fmt.Errorf("Error parsing the tweet trove for search query %q:\n %w", query, err)
return
}
// Filling tombstones and tombstoned users is probably not necessary here, but we still
// need to fetch Spaces
err = trove.PostProcess()
return
2021-11-06 14:55:15 -07:00
}