Quantcast
Channel: Taylor Hokanson
Viewing all articles
Browse latest Browse all 68

Opposable Thumbs Episode 4: Nick Bontrager/Stand Up Comedy

$
0
0

Meghan Trainor (no not that one) pitched us a curveball in Episode 3 with the “stand up comedy” challenge. Nick Bontranger was up to the task, and you can listen to his response here.

It occurred to me that I could enter this challenge in a completely straight-forward manner: by writing a traditional comedy set. This idea was immediately displaced by the urge to do something techie, so I started writing a script that could pull down humorous material from the web. Reddit seemed like a good place to look, given that it has a metric crapload of commentary to draw from (the following assumes you’re working in OSX).

  1. Make a new reddit account
  2. Follow these steps to create a script-type application (just follow the “first steps” section).
  3. Open your terminal and
    easy_install pip
      (may need sudo)
  4. Now create a virtual Python environment for your project and activate it. Do this so random updates don’t tank your script. Take special note of
    source venv/bin/activate
     , which will put you in virtual mode for the next steps.
  5. pip install praw
  6. python mybot.py
  7. This script looks for comments that include the words “tragedy” or “time” and prints them in the terminal.
  8. For the final output I installed Soundflower, which allowed me to record straight off the sound card. I then had the OSX accessibility assistants read the text aloud and laugh at it robotically.
  9. See python code below:

QUESTIONS = ['tragedy', 'time']

import praw
import time
x = True

# you'll need to get the stuff below yourself before this script will work
# https://github.com/reddit/reddit/wiki/OAuth2-Quick-Start-Example#first-steps

reddit = praw.Reddit(user_agent='YOUR_USER_AGENT', 
client_id='YOUR_CLIENT_ID', 
client_secret="YOUR_SECRET")

for comment in reddit.subreddit('all').stream.comments():
if x == True:
question_phrase = ' time '
if x == False:
question_phrase = 'trump'
if question_phrase in comment.body:
print(comment.body)
print("---")
x = not x


Viewing all articles
Browse latest Browse all 68

Latest Images

Trending Articles



Latest Images