Keep from echoing retweets/replies. Added reply field in tweet converter
This commit is contained in:
parent
e060e0d45d
commit
03e6c21120
3 changed files with 14 additions and 23 deletions
Binary file not shown.
|
@ -14,7 +14,8 @@ def convert_tweets(tweets):
|
||||||
'retweet':('RT @' in tweet.text),
|
'retweet':('RT @' in tweet.text),
|
||||||
'text':str(tweet.text.encode('utf-8'))[1:],
|
'text':str(tweet.text.encode('utf-8'))[1:],
|
||||||
'hashtags':tweet.entities.get('hashtags'),
|
'hashtags':tweet.entities.get('hashtags'),
|
||||||
'mentions':tweet.entities.get('user_metions')
|
'mentions':tweet.entities.get('user_metions'),
|
||||||
|
'reply':(tweet.in_reply_to_status_id_str)
|
||||||
})
|
})
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
@ -25,7 +26,8 @@ def convert_tweets(tweets):
|
||||||
'retweet':('RT @' in tweet.full_text),
|
'retweet':('RT @' in tweet.full_text),
|
||||||
'text':str(tweet.full_text.encode('utf-8'))[1:],
|
'text':str(tweet.full_text.encode('utf-8'))[1:],
|
||||||
'hashtags':tweet.entities.get('hashtags'),
|
'hashtags':tweet.entities.get('hashtags'),
|
||||||
'mentions':tweet.entities.get('user_metions')
|
'mentions':tweet.entities.get('user_metions'),
|
||||||
|
'reply':(tweet.in_reply_to_status_id_str)
|
||||||
})
|
})
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
@ -35,7 +37,8 @@ def convert_tweets(tweets):
|
||||||
'retweet':True,
|
'retweet':True,
|
||||||
'text':str(tweet.retweeted_status.text.encode("utf-8"))[1:],
|
'text':str(tweet.retweeted_status.text.encode("utf-8"))[1:],
|
||||||
'hashtags':tweet.entities.get('hashtags'),
|
'hashtags':tweet.entities.get('hashtags'),
|
||||||
'mentions':tweet.entities.get('user_metions')
|
'mentions':tweet.entities.get('user_metions'),
|
||||||
|
'reply':(tweet.in_reply_to_status_id_str)
|
||||||
})
|
})
|
||||||
|
|
||||||
return outtweets
|
return outtweets
|
|
@ -85,7 +85,7 @@ def echo_recent_tweets(screen_name):
|
||||||
language=None,
|
language=None,
|
||||||
idempotency_key=None)
|
idempotency_key=None)
|
||||||
'''
|
'''
|
||||||
|
if((not t['reply']) and (not t['retweet'])):
|
||||||
mastodon.status_post(
|
mastodon.status_post(
|
||||||
t['text'][1:-1],
|
t['text'][1:-1],
|
||||||
visibility='public',
|
visibility='public',
|
||||||
|
@ -101,15 +101,3 @@ if __name__ == '__main__':
|
||||||
with open('users.txt', 'r') as f:
|
with open('users.txt', 'r') as f:
|
||||||
for l in f:
|
for l in f:
|
||||||
echo_recent_tweets(l.rstrip())
|
echo_recent_tweets(l.rstrip())
|
||||||
|
|
||||||
# Clean these up
|
|
||||||
|
|
||||||
'''
|
|
||||||
#write the csv
|
|
||||||
with open('%s_tweets.csv' % screen_name, 'w') as f:
|
|
||||||
writer = csv.writer(f)
|
|
||||||
writer.writerow(["id","created_at","retweet","text","hashtags","user_mentions"])
|
|
||||||
writer.writerows(outtweets)
|
|
||||||
|
|
||||||
pass
|
|
||||||
'''
|
|
||||||
|
|
Reference in a new issue