Skip to content

Instantly share code, notes, and snippets.

@urielm
Forked from whs/gladosalarm.py
Created July 18, 2013 21:34
Show Gist options
  • Save urielm/6033308 to your computer and use it in GitHub Desktop.
Save urielm/6033308 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# READ FIRST
# This software poll HP2LY every 5 minutes and will play
# any ffmpeg supported file 20 times after 95%.
# To quit press Ctrl+C in Terminal.
# Closing ffplay would just respawn it.
#
# Dependency:
# Ubuntu: sudo apt-get install ffmpeg
# Fedora: su -c 'yum install ffmpeg'
# Mac OS X: Install MacPorts and sudo ports install ffmpeg
song = r"~/stillalive.mp4"
percent = 95
import urllib, commands, os, sys, time
from json import loads
while True:
p = urllib.urlopen("http://hasportal2launchedyet.com/data.json").read()
json = loads(p)
print "%s%% -- %s est. %s" % (
json['overall'],
time.ctime(time.time() + json['glados']['endpoint']),
time.ctime(time.time() + json['estimate']['endpoint'])
)
if json['overall'] > percent:
if sys.platform == "darwin":
# Mac: set volume to max
os.system("osascript -e 'set volume 7'")
else:
# Linux: set volume to max
os.system("amixer sset 'Master' 36 31")
for i in range(20):
print commands.getoutput("ffplay '"+os.path.expanduser(song)+"'")
break
time.sleep(60*5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment