def cmd_fetch(args): search = Search(args.credentials) while True: last_id = get_last_id(args.db) response = search.query(args.query, since_id=last_id) log_response(response) store_response(args.db, response, args.store_raw) sleep(args.throttle)
def cmd_backfill(args): search = Search(args.credentials) while True: # Note: Unlike since_id, max_id is inclusive # Cf.: https://dev.twitter.com/docs/working-with-timelines first_id = get_first_id(args.db) max_id = (first_id or sys.maxsize) - 1 response = search.query(args.query, max_id=max_id) log_response(response) store_response(args.db, response, args.store_raw) if not len(response.tweets): break else: sleep(args.throttle)