lib/twitterscraper/query.rb in twitterscraper-ruby-0.15.1 vs lib/twitterscraper/query.rb in twitterscraper-ruby-0.15.2

- old
+ new

@@ -26,11 +26,11 @@ RELOAD_URL_USER = 'https://twitter.com/i/profiles/show/__USER__/timeline/tweets?' + 'include_available_features=1&include_entities=1&' + 'max_position=__POS__&reset_error_state=false' def build_query_url(query, lang, type, pos) - if type == 'user' + if type.user? if pos RELOAD_URL_USER.sub('__USER__', query).sub('__POS__', pos.to_s) else INIT_URL_USER.sub('__USER__', query) end @@ -106,11 +106,11 @@ return [], (json_resp && json_resp['has_more_items'] && json_resp['min_position']) end if json_resp [tweets, json_resp['min_position']] - elsif type + elsif type.user? [tweets, tweets[-1].tweet_id] else [tweets, "TWEET-#{tweets[-1].tweet_id}-#{tweets[0].tweet_id}"] end end @@ -198,9 +198,10 @@ def query_tweets(query, type: 'search', start_date: nil, end_date: nil, lang: nil, limit: 100, daily_limit: nil, order: 'desc', threads: 2) start_date = Date.parse(start_date) if start_date && start_date.is_a?(String) end_date = Date.parse(end_date) if end_date && end_date.is_a?(String) queries = build_queries(query, start_date, end_date) + type = Type.new(type) if threads > queries.size logger.warn 'The maximum number of :threads is the number of dates between :start_date and :end_date.' threads = queries.size end if proxy_enabled?