Ejemplo n.º 1
0
Archivo: emit.py Proyecto: idreyn/robin
	def __init__(self, settings):
		self.buffer = SampleBuffer(channels=settings.output.channels)
		self.stream = create_stream(
			settings=settings,
			output=True,
			callback=lambda *args: self.playback(*args)
		)
Ejemplo n.º 2
0
	def __init__(self, settings):
		self.buffer = SampleBuffer(channels=settings.input.channels)
                self.settings = settings
		self.stream = create_stream(
			settings=settings,
			output=False,
			callback=lambda *args: self._recording(*args)
		)
Ejemplo n.º 3
0
def main():
    global isThreading
    auth = tweepy.OAuthHandler(get_credentials()['consumer_key'],
                               get_credentials()['consumer_secret'])
    auth.set_access_token(get_credentials()['access_token'],
                          get_credentials()['access_token_secret'])

    api = tweepy.API(auth)
    if not isThreading:
        th = threading.Thread(target=bot, args=(api, ))
        th.start()
        isThreading = True

    try:
        create_stream(api)
    except:
        print("[!!] ERRO NO STREAM, REINICIANDO...")
        main()
import sqlite3
from sqlite3 import Error
import stream as st
from time import strftime

stream = st.create_stream()
tweets, dt, future = st.get_stream(stream)

conn = sqlite3.connect("assign2.db")
db = conn.cursor()
db.execute('drop table if exists HASHTAGS;')
db.execute(
    'create table HASHTAGS (tag_ID integer primary key autoincrement,hashtag text);'
)
conn.commit()

for tweet in tweets:
    if 'entities' in tweet:
        hashtags = tweet['entities']['hashtags']
        for hashtag in hashtags:
            # print "%s" % (hashtag['text'])
            db.execute('INSERT INTO HASHTAGS (hashtag) VALUES (?);',
                       [hashtag['text']])
            conn.commit()

cur = db.execute(
    'select hashtag, count(*) as count from HASHTAGS group by hashtag order by count desc limit 10;'
)
top10 = cur.fetchall()

fp = open('assign2-report.txt', 'w')
Ejemplo n.º 5
0
import sqlite3
from sqlite3 import Error
import stream as twitter_stream
from time import strftime


stream = twitter_stream.create_stream()
tweet_buff, date_time, future = twitter_stream.get_stream(stream)

connection = sqlite3.connect("tweets.db")
tweet_db = connection.cursor()
tweet_db.execute('drop table if exists POPULAR_HASHTAG;')
tweet_db.execute('create table POPULAR_HASHTAG (tag_ID integer primary key autoincrement,hashtag text);')
connection.commit()
fp = open('report.txt', 'w')

for tweet in tweet_buff:
    if 'entities' in tweet:
        hashtags = tweet['entities']['hashtags']
        for hashtag in hashtags:
            tweet_db.execute('INSERT INTO POPULAR_HASHTAG (hashtag) VALUES (?);', [hashtag['text']])
            connection.commit()

result = tweet_db.execute('select hashtag, count(*) as count from POPULAR_HASHTAG group by hashtag order by count desc limit 10;')
popHashtags = result.fetchall()

print('{}\t{}'.format(date_time,future))
fp.write('{}\t{}\n'.format(date_time,future))
for popHashtag in popHashtags:
    print(popHashtag[0].encode('utf-8') + '\t{}'.format(popHashtag[1])) #encoding to  priduce hashtags in that are not in english
    fp.write(popHashtag[0].encode('utf-8') + '\t{}\n'.format(popHashtag[1]))