Example #1
0
    def json_to_status(self, response, column_id='', _type=StatusType.NORMAL):
        if isinstance(response, list):
            statuses = []
            for resp in response:
                if not resp:
                    continue
                status = self.json_to_status(resp, column_id, _type)
                if status.reposted_by:
                    # TODO: Handle this
                    #users = self.get_retweet_users(status.id_)
                    #status.reposted_by = users
                    #count = self.get_retweet_count(status.id_)
                    #status.reposted_count = count
                    pass
                statuses.append(status)
            return statuses
        else:
            reposted_by = None
            retweeted_id = None
            if response.has_key('retweeted_status'):
                reposted_by = response['user']['screen_name']
                retweeted_id = response['id']
                post = response['retweeted_status']
            else:
                post = response

            protected = False
            verified = False
            if post.has_key('user'):
                username = post['user']['screen_name']
                avatar = post['user']['profile_image_url']
                protected = post['user']['protected']
                verified = post['user']['verified']
            elif post.has_key('sender'):
                username = post['sender']['screen_name']
                avatar = post['sender']['profile_image_url']
                protected = post['sender']['protected']
                verified = post['sender']['verified']
            elif post.has_key('from_user'):
                username = post['from_user']
                avatar = post['profile_image_url']

            in_reply_to_id = None
            in_reply_to_user = None
            if post.has_key('in_reply_to_status_id') and \
               post['in_reply_to_status_id']:
                in_reply_to_id = post['in_reply_to_status_id']
                in_reply_to_user = post['in_reply_to_screen_name']

            fav = False
            if post.has_key('favorited'):
                fav = post['favorited']

            retweeted = False
            if post.has_key('retweeted'):
                retweeted = post['retweeted']

            source = None
            if post.has_key('source'):
                source = post['source']

            status = Status()
            status.id_ = str(post['id'])
            status.retweeted_id = retweeted_id
            status.username = username
            status.avatar = avatar
            status.source = self.get_source(source)
            status.text = post['text']
            status.in_reply_to_id = in_reply_to_id
            status.in_reply_to_user = in_reply_to_user
            status.is_favorite = fav
            status.is_protected = protected
            status.is_verified = verified
            status.reposted_by = reposted_by
            status.datetime = self.get_str_time(post['created_at'])
            status.timestamp = self.get_int_time(post['created_at'])
            status.entities = self.get_entities(post)
            status._type = _type
            status.account_id = self.account_id
            status.is_own = (username.lower() == self.uname.lower())
            status.retweeted = retweeted
            status.set_display_id(column_id)
            return status
Example #2
0
    def json_to_status(self, response, column_id='', _type=StatusType.NORMAL):
        if isinstance(response, list):
            statuses = []
            for resp in response:
                if not resp:
                    continue
                status = self.json_to_status(resp, column_id, _type)
                statuses.append(status)
            return statuses
        else:
            reposted_by = None
            if response.has_key('retweeted_status'):
                reposted_by = response['user']['screen_name']
                post = response['retweeted_status']
            else:
                post = response

            protected = False
            if post.has_key('user'):
                username = post['user']['screen_name']
                avatar = post['user']['profile_image_url']
                protected = post['user']['protected']
            elif post.has_key('sender'):
                username = post['sender']['screen_name']
                avatar = post['sender']['profile_image_url']
                protected = post['sender']['protected']
            elif post.has_key('from_user'):
                username = post['from_user']
                avatar = post['profile_image_url']

            in_reply_to_id = None
            in_reply_to_user = None
            if post.has_key('in_reply_to_status_id') and \
               post['in_reply_to_status_id']:
                in_reply_to_id = post['in_reply_to_status_id']
                in_reply_to_user = post['in_reply_to_screen_name']

            fav = False
            if post.has_key('favorited'):
                fav = post['favorited']

            source = None
            if post.has_key('source'):
                source = post['source']

            status = Status()
            status.id_ = str(post['id'])
            status.username = username
            status.avatar = avatar
            status.source = self.get_source(source)
            status.text = post['text']
            status.in_reply_to_id = in_reply_to_id
            status.in_reply_to_user = in_reply_to_user
            status.is_favorite = fav
            status.is_protected = protected
            status.is_verified = False
            status.reposted_by = reposted_by
            status.datetime = self.get_str_time(post['created_at'])
            status.timestamp = self.get_int_time(post['created_at'])
            status.entities = self.get_entities(post)
            status._type = _type
            status.account_id = self.account_id
            status.is_own = (username.lower() == self.uname.lower())
            status.set_display_id(column_id)
            return status
Example #3
0
    def json_to_status(self, response, column_id="", _type=StatusType.NORMAL):
        if isinstance(response, list):
            statuses = []
            for resp in response:
                if not resp:
                    continue
                status = self.json_to_status(resp, column_id, _type)
                statuses.append(status)
            return statuses
        else:
            reposted_by = None
            if "retweeted_status" in response:
                reposted_by = response["user"]["screen_name"]
                post = response["retweeted_status"]
            else:
                post = response

            protected = False
            if "user" in post:
                username = post["user"]["screen_name"]
                avatar = post["user"]["profile_image_url"]
                protected = post["user"]["protected"]
            elif "sender" in post:
                username = post["sender"]["screen_name"]
                avatar = post["sender"]["profile_image_url"]
                protected = post["sender"]["protected"]
            elif "from_user" in post:
                username = post["from_user"]
                avatar = post["profile_image_url"]

            in_reply_to_id = None
            in_reply_to_user = None
            if "in_reply_to_status_id" in post and post["in_reply_to_status_id"]:
                in_reply_to_id = post["in_reply_to_status_id"]
                in_reply_to_user = post["in_reply_to_screen_name"]

            fav = False
            if "favorited" in post:
                fav = post["favorited"]

            source = None
            if "source" in post:
                source = post["source"]

            status = Status()
            status.id_ = str(post["id"])
            status.username = username
            status.avatar = avatar
            status.source = self.get_source(source)
            status.text = post["text"]
            status.in_reply_to_id = in_reply_to_id
            status.in_reply_to_user = in_reply_to_user
            status.is_favorite = fav
            status.is_protected = protected
            status.is_verified = False
            status.reposted_by = reposted_by
            status.datetime = self.get_str_time(post["created_at"])
            status.timestamp = self.get_int_time(post["created_at"])
            status.entities = self.get_entities(post)
            status._type = _type
            status.account_id = self.account_id
            status.is_own = username.lower() == self.uname.lower()
            status.set_display_id(column_id)
            return status
Example #4
0
    def json_to_status(self, response, column_id='', type_=Status.NORMAL):
        if isinstance(response, list):
            statuses = []
            for resp in response:
                if not resp:
                    continue
                status = self.json_to_status(resp, column_id, type_)
                statuses.append(status)
            return statuses
        else:
            repeated_by = None
            retweeted_id = None
            if 'retweeted_status' in response:
                repeated_by = response['user']['screen_name']
                retweeted_id = response['id']
                post = response['retweeted_status']
            else:
                post = response

            protected = False
            verified = False
            if 'user' in post:
                username = post['user']['screen_name']
                avatar = post['user']['profile_image_url']
                protected = post['user']['protected']
                verified = post['user']['verified']
            elif 'sender' in post:
                username = post['sender']['screen_name']
                avatar = post['sender']['profile_image_url']
                protected = post['sender']['protected']
                verified = post['sender']['verified']
            elif 'from_user' in post:
                username = post['from_user']
                avatar = post['profile_image_url']

            in_reply_to_id = None
            in_reply_to_user = None
            if 'in_reply_to_status_id' in post and \
                    post['in_reply_to_status_id']:
                in_reply_to_id = post['in_reply_to_status_id']
                if 'in_reply_to_screen_name' in post:
                    in_reply_to_user = post['in_reply_to_screen_name']

            fav = False
            if 'favorited' in post:
                fav = post['favorited']

            repeated = False
            if 'retweeted' in post:
                repeated = post['retweeted']

            source = None
            if 'source' in post:
                source = post['source']

            retweet_count = None
            if 'retweet_count' in post:
                retweet_count = int(post['retweet_count'])

            status = Status()
            status.id_ = str(post['id'])
            status.original_status_id = retweeted_id
            status.created_at = post['created_at']
            status.username = username
            status.avatar = avatar
            status.text = post['text']
            status.in_reply_to_id = in_reply_to_id
            status.in_reply_to_user = in_reply_to_user
            status.is_favorite = fav
            status.is_protected = protected
            status.is_verified = verified
            status.repeated_by = repeated_by
            status.datetime = self.get_str_time(post['created_at'])
            status.timestamp = self.get_int_time(post['created_at'])
            status.entities = self.get_entities(post)
            status.type_ = type_
            status.account_id = self.account_id
            status.is_own = (username.lower() == self.uname.lower())
            status.repeated = repeated
            status.repeated_count = retweet_count
            status.local_timestamp = timestamp_to_localtime(status.timestamp)
            status.get_source(source)
            return status
Example #5
0
    def json_to_status(self, response, column_id='', type_=Status.NORMAL):
        if isinstance(response, list):
            statuses = []
            for resp in response:
                if not resp:
                    continue
                status = self.json_to_status(resp, column_id, type_)
                statuses.append(status)
            return statuses
        else:
            repeated_by = None
            retweeted_id = None
            if 'retweeted_status' in response:
                repeated_by = response['user']['screen_name']
                retweeted_id = response['id']
                post = response['retweeted_status']
            else:
                post = response

            protected = False
            verified = False
            if 'user' in post:
                username = post['user']['screen_name']
                avatar = post['user']['profile_image_url']
                protected = post['user']['protected']
                verified = post['user']['verified']
            elif 'sender' in post:
                username = post['sender']['screen_name']
                avatar = post['sender']['profile_image_url']
                protected = post['sender']['protected']
                verified = post['sender']['verified']
            elif 'from_user' in post:
                username = post['from_user']
                avatar = post['profile_image_url']

            in_reply_to_id = None
            in_reply_to_user = None
            if 'in_reply_to_status_id' in post and \
                    post['in_reply_to_status_id']:
                in_reply_to_id = post['in_reply_to_status_id']
                if 'in_reply_to_screen_name' in post:
                    in_reply_to_user = post['in_reply_to_screen_name']

            fav = False
            if 'favorited' in post:
                fav = post['favorited']

            repeated = False
            if 'retweeted' in post:
                repeated = post['retweeted']

            source = None
            if 'source' in post:
                source = post['source']

            retweet_count = None
            if 'retweet_count' in post:
                retweet_count = int(post['retweet_count'])

            status = Status()
            status.id_ = str(post['id'])
            status.original_status_id = retweeted_id
            status.created_at = post['created_at']
            status.username = username
            status.avatar = avatar
            status.text = post['text']
            status.in_reply_to_id = in_reply_to_id
            status.in_reply_to_user = in_reply_to_user
            status.is_favorite = fav
            status.is_protected = protected
            status.is_verified = verified
            status.repeated_by = repeated_by
            status.datetime = self.get_str_time(post['created_at'])
            status.timestamp = self.get_int_time(post['created_at'])
            status.entities = self.get_entities(post)
            status.type_ = type_
            status.account_id = self.account_id
            status.is_own = (username.lower() == self.uname.lower())
            status.repeated = repeated
            status.repeated_count = retweet_count
            status.local_timestamp = timestamp_to_localtime(status.timestamp)
            status.get_source(source)
            return status