-
Notifications
You must be signed in to change notification settings - Fork 0
/
fts.py
executable file
·46 lines (34 loc) · 1.4 KB
/
fts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import datetime as dt
from collections import Counter
import twitter
api = twitter.Api(consumer_key="SEE README",
consumer_secret="SEE README",
access_token_key="SEE README",
access_token_secret="SEE README")
favs = api.GetFavorites(count=200)
users_liked = [t.user.screen_name for t in favs]
counts = Counter(users_liked)
users_with_likes = [item for item in counts]
counts_sorted = [(counts[item],item) for item in counts if counts[item]>1]
counts_sorted.sort()
if counts_sorted != None:
for (count,item) in counts_sorted:
print item,":",count
print "Did not receive likes sorted by activity:"
following = [item.screen_name for item in api.GetFriends()]
unpopular = [item for item in following if item not in users_with_likes]
unpopular_weighted = []
a = dt.datetime.now()
for user in unpopular:
tweets = api.GetUserTimeline(screen_name=user,count=10)
if len(tweets) > 0:
oldest = tweets[-1].created_at
b = dt.datetime.strptime(tweets[-1].created_at,"%a %b %d %X +0000 %Y")
delay = (a-b).total_seconds()
unpopular_weighted.extend([(delay/len(tweets),user)])
print user,": ", len(tweets)*864000/delay, "tweets per day."
print "Sorted below, --------------------------------------------"
unpopular_weighted.sort()
for (weight,item) in unpopular_weighted:
print item,": Approx.", 864000/weight, "tweets per day."