Created
September 28, 2011 21:43
-
-
Save jiaaro/1249337 to your computer and use it in GitHub Desktop.
Check for radiohead tickets :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
I really *REALLY* wanted to see Radiohead at Roseland ballroom, but so | |
did everybody else and the tickets sold out in about 10 minutes. I didn't | |
get one :( | |
They haven't played in NYC in 3 years! | |
Here is a script that checks when tickets become available for an event. | |
NEVER AGAIN! | |
""" | |
# The urls of the respective events on Ticketmaster | |
# These urls are for Radiohead at roseland ballroom, which | |
# sold out in about 5 minutes :( | |
EVENT_URLS = [ | |
# Wednesday Show | |
"http://www.ticketmaster.com/event/0000472D9AFBA224", | |
# Thursday Show | |
"http://www.ticketmaster.com/event/0000472D9EE2A753" | |
] | |
from sys import stdout | |
import time | |
import webbrowser | |
import urllib | |
from random import randint | |
try: | |
# If you have mac we'll use py-appscript (pip install appscript) | |
# to pop up a modal dialog and say a message through the speakers | |
import osax | |
sa = osax.OSAX() | |
def dialog(msg, **kwargs): | |
# Give the app focus so the dialog will be on top | |
sa.activate() | |
# Open the dialog | |
return sa.display_dialog(msg, **kwargs) | |
def say(msg): | |
# Max volume (0 - 7 scale) | |
sa.set_volume(7) | |
# This spelling is for fun pronounciation | |
sa.say("i finded yer teekutz") | |
except ImportError: | |
def dialog(msg, **kwargs): | |
printnow(msg) | |
def say(*args, **kwargs): pass | |
def printnow(msg): | |
stdout.write(msg) | |
stdout.flush() | |
def randsleep(min, max): | |
time.sleep(randint(min, max)) | |
def tickets_available_for(event_url): | |
html = urllib.urlopen(event_url).read() | |
printnow(".") | |
return "Tickets Not Available" not in html | |
print "Searching for tickets..." | |
while True: | |
for event in EVENT_URLS: | |
if tickets_available_for(event): | |
say("i can has yoar teekitz") | |
dialog("Found tickets!", buttons=["View in browser"]) | |
webbrowser.open_new(url=event) | |
# ~5 seconds between calls (let's be polite) | |
randsleep(4, 8) | |
# ~60 seconds between checks | |
randsleep(45, 65) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment