Created
July 17, 2015 01:41
-
-
Save glortho/590bd9d33e0c120ed586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
"exec" "twxec" "-e" "pare_data_structure" "$0" "$@" | |
def pare_data_structure(msg): | |
pmsg = {} | |
pmsg['body'] = msg['body'] | |
pmsg['link'] = msg['link'] | |
pmsg['umens'] = msg['umens'] | |
pmsg['actor'] = {'languages': msg['actor']['languages'], | |
'preferredUsername': msg['actor']['preferredUsername'], | |
'postedTime': msg['actor']['postedTime'], | |
'id': msg['actor']['id'], | |
'link': msg['actor']['link']} | |
pmsg['gnip'] = {'matching_rules': msg['gnip']['matching_rules'], | |
'profileLocations': msg['gnip'].get('profileLocations')} | |
# Location Information, if available | |
pmsg['location'] = msg.get('location') | |
pmsg['geo'] = msg.get('geo') | |
pmsg['retweetCount'] = msg['retweetCount'] | |
pmsg['postedTime'] = msg['postedTime'] | |
pmsg['twitter_lang'] = msg['twitter_lang'] | |
pmsg['twitter_entities'] = {'media': msg['twitter_entities'].get('media'), | |
'urls': msg['twitter_entities']['urls'], | |
'hastags': msg['twitter_entities']['hashtags']} | |
pmsg['object'] = {'postedTime': msg['object']['postedTime']} | |
if msg['object'].get('actor') is not None: | |
pmsg['object']['actor'] = {'preferredUsername': msg['object']['actor']['preferredUsername']} | |
pmsg['object']['twitter_entities'] = {'user_mentions': msg['object']['twitter_entities']['user_mentions']} | |
return pmsg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment