def retweet_user_id(t: Dict) -> str: """ Integer value Tweet ID of the Original Tweeter """ with suppress(KeyError): return pluck(t, 'retweeted_status.user.id_str') with suppress(KeyError): return pluck(t, 'quoted_status.user.id_str') return ""
def retweet_screen_name(t: Dict) -> str: """ Name of Original Tweeter """ with suppress(KeyError): return pluck(t, 'retweeted_status.user.screen_name') with suppress(KeyError): return pluck(t, 'quoted_status.user.screen_name') return ""
def retweet_id(t: Dict) -> str: """ integer value Tweet ID of the retweeted or quoted Tweet """ with suppress(KeyError): return pluck(t, 'retweeted_status.id_str') with suppress(KeyError): return pluck(t, 'quoted_status.id_str') return ""
def extended_text(t: Dict) -> str: with suppress(KeyError): return pluck(t, 'extended_tweet.full_text') with suppress(KeyError): return pluck(t, 'retweeted_status.extended_tweet.full_text') with suppress(KeyError): return pluck(t, 'quoted_status.extended_tweet.full_text') return ''
def media(t: Dict) -> str: """ An expanded version of display_url. Links to the media display page """ with suppress(KeyError): m = pluck(t, 'extended_entities.media') if m: return ' '.join([h['expanded_url'] for h in m]) with suppress(KeyError): m = pluck(t, 'entities.media') if m: return ' '.join([h['expanded_url'] for h in m]) return ''
def hashtags(t: Dict) -> str: """ Get all hashtags, including when tweet is truncated (if available) """ with suppress(KeyError): # noinspection PyTypeChecker return ' '.join([ h['text'] for h in pluck(t, 'retweeted_status.entities.hashtags') ]) # extended tweet with suppress(KeyError): # noinspection PyTypeChecker return ' '.join( [h['text'] for h in pluck(t, 'extended_tweet.entities.hashtags')]) # standard hashtag field return ' '.join([h['text'] for h in t['entities']['hashtags']])
def place(t: Dict) -> str: """ Full human-readable representation of the place’s name (if available) """ with suppress(TypeError): return pluck(t, 'place.full_name') return ''
def coordinates(t: Dict) -> str: """ Get location coordinates in the form [longitude, latitude] (if available) """ with suppress(TypeError): return '%f %f' % tuple(pluck(t, 'coordinates.coordinates')) return ''
def quoted_or_retweeted_hashtags(t: Dict) -> str: """ Get quoted or retweeted hashtags """ # retweets with suppress(KeyError): return ' '.join([ h['text'] for h in pluck( t, 'retweeted_status.extended_tweet.entities.hashtags') ]) # quotes with suppress(KeyError): return ' '.join([ h['text'] for h in pluck(t, 'quoted_status.extended_tweet.entities.hashtags') ]) return ''
def text(t: Dict) -> str: """ Get text of tweet """ with suppress(KeyError): return pluck(t, 'retweeted_status.full_text') return t.get('full_text') or t.get('extended_tweet', {}).get('full_text') or t['text']
def user_urls(t: Dict) -> str: """ url of the Tweeter """ with suppress(KeyError): u = pluck(t, 'user.entities.url.urls') # noinspection PyTypeChecker,PyTypeChecker return " ".join( [url['expanded_url'] for url in u if url['expanded_url']]) return ""
def quote(t: Dict) -> str: with suppress(KeyError): return pluck(t, 'quoted_status.text') return ''