From 66780eb8015602aaeaa3b3dbffb70c5c8d0a5687 Mon Sep 17 00:00:00 2001 From: Alexander Sheiko Date: Thu, 11 May 2023 14:15:56 +0300 Subject: [PATCH] Remove deprecated functions Removed global default scraper --- profile.go | 5 ----- scraper.go | 26 -------------------------- search.go | 10 ---------- trends.go | 5 ----- tweets.go | 10 ---------- 5 files changed, 56 deletions(-) diff --git a/profile.go b/profile.go index f295910..f6038ef 100644 --- a/profile.go +++ b/profile.go @@ -75,11 +75,6 @@ func (s *Scraper) GetProfile(username string) (Profile, error) { return parseProfile(jsn.Data.User.Legacy), nil } -// Deprecated: GetProfile wrapper for default scraper -func GetProfile(username string) (Profile, error) { - return defaultScraper.GetProfile(username) -} - // GetUserIDByScreenName from API func (s *Scraper) GetUserIDByScreenName(screenName string) (string, error) { id, ok := cacheIDs.Load(screenName) diff --git a/scraper.go b/scraper.go index cd3d7bf..1598b71 100644 --- a/scraper.go +++ b/scraper.go @@ -46,8 +46,6 @@ const ( // default http client timeout const DefaultClientTimeout = 10 * time.Second -var defaultScraper *Scraper - // New creates a Scraper object func New() *Scraper { jar, _ := cookiejar.New(nil) @@ -76,33 +74,18 @@ func (s *Scraper) SetSearchMode(mode SearchMode) *Scraper { return s } -// Deprecated: SetSearchMode wrapper for default Scraper -func SetSearchMode(mode SearchMode) *Scraper { - return defaultScraper.SetSearchMode(mode) -} - // WithDelay add delay between API requests (in seconds) func (s *Scraper) WithDelay(seconds int64) *Scraper { s.delay = seconds return s } -// Deprecated: WithDelay wrapper for default Scraper -func WithDelay(seconds int64) *Scraper { - return defaultScraper.WithDelay(seconds) -} - // WithReplies enable/disable load timeline with tweet replies func (s *Scraper) WithReplies(b bool) *Scraper { s.includeReplies = b return s } -// Deprecated: WithReplies wrapper for default Scraper -func WithReplies(b bool) *Scraper { - return defaultScraper.WithReplies(b) -} - // client timeout func (s *Scraper) WithClientTimeout(timeout time.Duration) *Scraper { s.client.Timeout = timeout @@ -149,12 +132,3 @@ func (s *Scraper) SetProxy(proxyAddr string) error { } return errors.New("only support http(s) or socks5 protocol") } - -// Deprecated: SetProxy wrapper for default Scraper -func SetProxy(proxy string) error { - return defaultScraper.SetProxy(proxy) -} - -func init() { - defaultScraper = New() -} diff --git a/search.go b/search.go index 63b0605..a907d56 100644 --- a/search.go +++ b/search.go @@ -11,21 +11,11 @@ func (s *Scraper) SearchTweets(ctx context.Context, query string, maxTweetsNbr i return getTweetTimeline(ctx, query, maxTweetsNbr, s.FetchSearchTweets) } -// Deprecated: SearchTweets wrapper for default Scraper -func SearchTweets(ctx context.Context, query string, maxTweetsNbr int) <-chan *TweetResult { - return defaultScraper.SearchTweets(ctx, query, maxTweetsNbr) -} - // SearchProfiles returns channel with profiles for a given search query func (s *Scraper) SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult { return getUserTimeline(ctx, query, maxProfilesNbr, s.FetchSearchProfiles) } -// Deprecated: SearchProfiles wrapper for default Scraper -func SearchProfiles(ctx context.Context, query string, maxProfilesNbr int) <-chan *ProfileResult { - return defaultScraper.SearchProfiles(ctx, query, maxProfilesNbr) -} - // getSearchTimeline gets results for a given search query, via the Twitter frontend API func (s *Scraper) getSearchTimeline(query string, maxNbr int, cursor string) (*timeline, error) { if !s.isLogged { diff --git a/trends.go b/trends.go index 943415a..6fc3515 100644 --- a/trends.go +++ b/trends.go @@ -35,8 +35,3 @@ func (s *Scraper) GetTrends() ([]string, error) { return trends, nil } - -// Deprecated: GetTrends wrapper for default Scraper -func GetTrends() ([]string, error) { - return defaultScraper.GetTrends() -} diff --git a/tweets.go b/tweets.go index bbba2a1..7eee270 100644 --- a/tweets.go +++ b/tweets.go @@ -11,11 +11,6 @@ func (s *Scraper) GetTweets(ctx context.Context, user string, maxTweetsNbr int) return getTweetTimeline(ctx, user, maxTweetsNbr, s.FetchTweets) } -// Deprecated: GetTweets wrapper for default Scraper -func GetTweets(ctx context.Context, user string, maxTweetsNbr int) <-chan *TweetResult { - return defaultScraper.GetTweets(ctx, user, maxTweetsNbr) -} - // FetchTweets gets tweets for a given user, via the Twitter frontend API. func (s *Scraper) FetchTweets(user string, maxTweetsNbr int, cursor string) ([]*Tweet, string, error) { userID, err := s.GetUserIDByScreenName(user) @@ -76,8 +71,3 @@ func (s *Scraper) GetTweet(id string) (*Tweet, error) { } return nil, fmt.Errorf("tweet with ID %s not found", id) } - -// Deprecated: GetTweet wrapper for default Scraper -func GetTweet(id string) (*Tweet, error) { - return defaultScraper.GetTweet(id) -}