phenny-1/modules/wuvt.py

30 lines
801 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")
dj = trackinfo['dj'].strip()
if dj[0:3] != 'DJ ':
dj = 'DJ {}'.format(dj)
2012-05-27 22:30:59 -04:00
2015-03-05 19:14:46 -05:00
phenny.say("{dj} is currently playing {title} by {artist}".format(
dj=dj,
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'