Ieva and Emily: Cat Detectives (in training)

import ddf.minim.*;
//import twitter4j-4.0.1.*;
//import twitter4j.api.*;
//import java.util.*;

//audio
AudioPlayer player;
Minim minim;

PImage backimage;
PImage sloth;
PImage catFace;

//Query query;
//Twitter twitter;

void setup() {  

  //Set the size of the stage, and the background to black.
  size(700, 700);
  backimage = loadImage("compcat.jpg");
  sloth = loadImage ("slothallday.jpg");
  catFace = loadImage ("buny_cat.jpg");
  smooth();

 ConfigurationBuilder cb = new ConfigurationBuilder();
 cb.setOAuthConsumerKey("EKTjLWa6EOFXhfthNTP8A");
 cb.setOAuthConsumerSecret("ZTsfvECqYSLF57E3mRLTLm3zevUzLIjEateUSSfPU");
cb.setOAuthAccessToken("329517248-TDTpfMwx6fn1n6O6VpIzmdqpcugbVfJGluNau8Xv");
  cb.setOAuthAccessTokenSecret("DzfsSJmkK1WcqmYAAa2XPoAgaIY8A3H84puznWyeLBrHV");

  //initialize minim
  minim = new Minim(this);
  player = minim.loadFile("catcat.mp3");
  player.play();

  //Make the twitter object and prepare the query
 Twitter twitter = new TwitterFactory(cb.build()).getInstance();
 Query query = new Query("#cat");
 query.setCount(100);

 //Try making the query request.
 try {
 QueryResult result = twitter.search(query);
 List tweets = result.getTweets();

 for (int i = 0; i < tweets.size(); i++) {
 Tweet t = (Tweet) tweets.get(i);
 String user = t.getFromUser();
 String msg = t.getText();
 Date d = t.getCreatedAt();
 println("Tweet by " + user + " at " + d + ": " + msg);

 //Break the tweet into words
 String[] input = msg.split(" ");
 for (int j = 0;  j < input.length; j++) {
 //Put each word into the words ArrayList
 words.add(input[j]);
 }
 };
 }
 catch (TwitterException te) {
 println("Couldn't connect: " + te);
 };
 }

void draw() {
  background(backimage);

  //Draw a word from the list of words that we've built
  //int i = (frameCount % words.size());
  // String word = words.get(i);

  // Put it somewhere random on the stage, with a random size and colour
  fill(255, random(50, 150));
  textSize(random(10, 30));
  //  text(word, random(width), random(height));

  //ieva's dumb people code thinking

 // if tweet contains word cat {
 //   draw (catFace);
 // }

 // if tweet does not contain word cat{
//  background (sloth);
  //}

}

 

Leave a Reply