Repository navigation
Expand file tree
/
Copy pathTweeterMachine.py
More file actions
51 lines (35 loc) · 1.44 KB
/
Copy pathTweeterMachine.py
File metadata and controls
51 lines (35 loc) · 1.44 KB
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
46
47
48
49
50
51
import tweepy
from Locator import Locator
class TweeterMachine:
#setting the values for the API access
CONSUMER_KEY = 'FeOfRApXuY4VFiLUN9Y19rGbK'
CONSUMER_SECRET = 'gPdqBBrhW3OV7eDZc21HXBZW7GlcIJrAN1mF1SELc31wR7LLjo'
ACCESS_TOKEN = '883048363264004096-dp0Ut1tFvtetzNzpWc6uqhNmpek1sxX'
ACCESS_TOKEN_SECRET = '4X5CgMtdAb1Qltyh2E0ghblvmpxwvsVezZOfLGhZwiaYa'
#Create a twitter api instance
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
api.wait_on_rate_limit = True
api.wait_on_rate_limit_notify = True
#tweeted songs
songSet = set()
#finding location
location = Locator()
#your hashtag
hashtag = input('Please Enter your selected Hashtag: ')
def __init__(self):
pass
def get_tweets(self):
#finds and adds the songs that have been tweeted
for tweet in tweepy.Cursor(self.api.search, q = '{}'.format(self.hashtag), lang = 'en',
geocode = '{},{},10km'.format(self.location.get_latitude(),self.location.get_longitude())).items():
# print(tweet)
if len(tweet.text.split(' , ')) > 1 :
self.songSet.add(tweet.text.split(' , ')[1].title())
def get_songs(self):
# print(self.songSet)
return self.songSet
def reset_songSet(self):
self.songSet.clear()
# print(self.songSet)