· 8 years ago · Dec 22, 2016, 07:22 AM
1import time
2import os
3from twython import TwythonStreamer
4
5# Search terms
6TERMS = 'om telolet om'
7
8# Twitter application authentication
9APP_KEY = ' '
10APP_SECRET = ' '
11OAUTH_TOKEN = ' '
12OAUTH_TOKEN_SECRET = ' '
13
14# Setup callbacks from Twython Streamer
15class BlinkyStreamer(TwythonStreamer):
16 def on_success(self, data):
17 if 'text' in data:
18 print data['text'].encode('utf-8')
19 print
20 os.system("omxplayer -o local telolet.mp3")
21 print "ok"
22
23# Create streamer
24try:
25 stream = BlinkyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
26 stream.statuses.filter(track=TERMS)
27except KeyboardInterrupt:
28 print "done"