Ejemplo n.º 1
0
    def on_status(self, status):

        if status.lang == 'en':
            # Insert new tweet IF has 'retweeted_status'
            if hasattr(status, 'retweeted_status'):
                print("{} is retweeting {}.".format(
                    status.id_str, status.retweeted_status.id_str))

                tweet = Tweet()
                # Check if retweeted_status already exist
                if tweet.is_tweet_exist(status.retweeted_status.id_str) != 0:
                    print("{} found!".format(status.retweeted_status.id_str))
                    self.update(status.retweeted_status)
                else:
                    print("{} not found.".format(
                        status.retweeted_status.id_str))
                    self.create(status.retweeted_status)

            self.create(status)

            print('Total {} status(es) inserted.\n'.format(self.count))
        else:
            print('Not an English tweet. Skipped.\n'
                  )  # TODO : need count of skipped tweet? maybe?