2012-05-27 22:30:59 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
wuvt.py - Phenny WUVT Module
|
|
|
|
Copyright 2012, Randy Nance, randynance.info
|
|
|
|
|
|
|
|
http://github.com/randynobx/phenny/
|
|
|
|
"""
|
|
|
|
|
2012-06-02 01:17:09 -04:00
|
|
|
from tools import GrumbleError
|
2012-05-27 22:30:59 -04:00
|
|
|
import re
|
|
|
|
import web
|
|
|
|
|
|
|
|
re.MULTILINE
|
|
|
|
r_play = re.compile(r'^(.*?) - (.*?)$')
|
|
|
|
r_dj = re.compile(r'Current DJ: </span>\n(.+?)<')
|
|
|
|
|
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:
|
|
|
|
playing = web.get('http://www.wuvt.vt.edu/playlists/latest_track.php')
|
|
|
|
djpage = web.get('http://www.wuvt.vt.edu/playlists/current_dj.php')
|
2013-06-09 01:27:24 -04:00
|
|
|
except:
|
2012-06-02 01:17:09 -04:00
|
|
|
raise GrumbleError('Cannot connect to wuvt')
|
2012-05-27 22:30:59 -04:00
|
|
|
play= r_play.search(playing)
|
2012-06-10 01:14:08 -04:00
|
|
|
song = play.group(2)
|
|
|
|
artist = play.group(1)
|
2012-05-27 22:30:59 -04:00
|
|
|
dj = r_dj.search(djpage).group(1)
|
|
|
|
|
|
|
|
if song and artist:
|
2014-11-07 22:44:44 -05:00
|
|
|
if dj.strip()[0:3] == 'DJ ':
|
2014-11-07 21:40:04 -05:00
|
|
|
phenny.reply('{0} is currently playing: {1} by {2}'
|
|
|
|
.format(dj.strip(), song.strip(), artist.strip()))
|
|
|
|
else:
|
|
|
|
phenny.reply('DJ {0} is currently playing: {1} by {2}'
|
|
|
|
.format(dj.strip(), song.strip(), artist.strip()))
|
2012-05-27 22:30:59 -04:00
|
|
|
else:
|
|
|
|
phenny.reply('Cannot connect to wuvt')
|
|
|
|
wuvt.commands = ['wuvt']
|