phenny-1/modules/wuvt.py

26 lines
731 B
Python
Raw Normal View History

2012-05-27 22:30:59 -04:00
#!/usr/bin/env python
"""
2015-03-05 19:14:46 -05:00
wuvt.py - WUVT now playing module for phenny
2012-05-27 22:30:59 -04:00
"""
from tools import GrumbleError
2012-05-27 22:30:59 -04:00
import web
2013-10-05 19:20:37 -04:00
def wuvt(phenny, input):
""".wuvt - Find out what is currently playing on the radio station WUVT."""
2012-05-27 22:30:59 -04:00
try:
2015-03-05 19:14:46 -05:00
data = web.get('https://www.wuvt.vt.edu/playlists/latest_track',
headers={'Accept': "application/json"})
trackinfo = web.json(data)
2013-06-09 01:27:24 -04:00
except:
2015-03-05 19:14:46 -05:00
raise GrumbleError("Failed to fetch current track from WUVT")
phenny.say("{dj} is currently playing {title} by {artist}".format(
2015-03-20 22:16:39 -04:00
dj=trackinfo['dj'].strip(),
2015-03-05 19:14:46 -05:00
title=trackinfo['title'].strip(),
artist=trackinfo['artist'].strip()))
2012-05-27 22:30:59 -04:00
wuvt.commands = ['wuvt']
2015-03-05 19:14:46 -05:00
wuvt.example = '.wuvt'