def getAPI(): access_token, access_secret, consumer_key, consumer_secret = getKeys() auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_secret) api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True) return api
import sys import tweepy import json import keys from pymongo import MongoClient twitterKeys = keys.getKeys() CONSUMER_TOKEN=twitterKeys[0] CONSUMER_SECRET=twitterKeys[1] MY_ACCESS_TOKEN=twitterKeys[2] MY_ACCESS_SECRET=twitterKeys[3] auth = tweepy.OAuthHandler(CONSUMER_TOKEN, CONSUMER_SECRET) auth.set_access_token(MY_ACCESS_TOKEN, MY_ACCESS_SECRET) api = tweepy.API(auth) ### MONGO CONNECTION ### def connect(): mongo_keys = keys.mongoKeys() connection = MongoClient(mongo_keys[0],mongo_keys[1]) handle = connection[mongo_keys[2]] handle.authenticate(mongo_keys[3],mongo_keys[4]) return handle handle = connect() twitter_collection = handle.collected_tweets class CustomStreamListener(tweepy.StreamListener): # ... def on_status(self, status): try:
import pyglet import keys import buttons import presets import chordGenerator import copy from pyglet.window import mouse from pyglet import font window = pyglet.window.Window(1280, 720, resizable = False) keyList = keys.getKeys() font.add_file('montserrat semibold.otf') labels = pyglet.graphics.Batch() toneButtonsBatch = buttons.toneButtonsBatch keyButtonsBatch = buttons.keyButtonsBatch chordButtonsBatch = buttons.chordButtonsBatch presetButtonsBatch = buttons.presetButtonsBatch speedButtonsBatch = buttons.speedButtonsBatch tonalityButtons = buttons.tonalityButtons keyButtons = buttons.keyButtons chordButtons = buttons.chordButtons presetButtons = buttons.presetButtons speedButtons = buttons.speedButtons logo = pyglet.sprite.Sprite(pyglet.image.load("logo.png"), x = 25, y = 615, batch = labels) tonalityLabel = pyglet.text.Label("TONALITY", x = 70, y = 605, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels) keyLabel = pyglet.text.Label("KEY", x = 70, y = 550, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels) chordLabel = pyglet.text.Label("CHORD", x = 70, y = 495, font_name = 'Montserrat SemiBold', font_size = 24, color = (218,240,37,255), anchor_x ='left', anchor_y = 'center', batch = labels) presetsLabel = pyglet.text.Label("Presets:", x = 60, y = 35, font_name = 'Montserrat SemiBold', font_size = 24, anchor_x = 'left', anchor_y = 'center', batch = labels)
organizedHashtags = addTweetToDict(organizedHashtags, tweet, hashtagString) for hashtagString in organizedHashtags.keys(): organizedHashtags[hashtagString]["user_photos"]=list(set(organizedHashtags[hashtagString]["user_photos"])) organizedHashtags[hashtagString]["tweets"].sort(key=lambda x: x["created_at"], reverse=True) organizedHashtags[hashtagString]["most_recent"]=organizedHashtags[hashtagString]["tweets"][0]["created_at"] organizedHashtags[hashtagString]["hashtagString"] = hashtagString organizedHashtags[hashtagString]["raw_data"]=json.dumps(organizedHashtags[hashtagString], default=json_util.default) hashtagList = sortHashtagstoList(organizedHashtags) return hashtagList app = Flask(__name__) #static_url_path='/static' app.secret_key = 'medialab' twitterKeys = keys.getKeys() CONSUMER_TOKEN=twitterKeys[0] CONSUMER_SECRET=twitterKeys[1] MY_ACCESS_TOKEN=twitterKeys[2] MY_ACCESS_SECRET=twitterKeys[3] #CALLBACK_URL = 'http://8d5cf986.ngrok.io/verify' CALLBACK_URL = 'http://127.0.0.1:5000/verify' # session = dict() #you can save these values to a database def groupnameToHashtag(name): return "#" + name.replace(" ", "_") @app.template_filter('hashtagToGroupname') def hashtagToGroupname(hashtag): # print hashtag