diff options
-rw-r--r-- | modules/mahou_showtime.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/mahou_showtime.py b/modules/mahou_showtime.py index 7e3dba6..60bae97 100644 --- a/modules/mahou_showtime.py +++ b/modules/mahou_showtime.py @@ -20,22 +20,24 @@ class Module: search = [x.lower() for x in search.split()] try: - if time.time() - self.lastcache >= 3600 or not self.cache: - self.cache = urllib2.urlopen('http://www.mahou.org/Showtime/Showtime.html').read() + if time.time() - self.lastcache >= 60 or not self.cache: + self.cache = urllib2.urlopen('http://www.mahou.org/Showtime/').read() self.lastcache = time.time() except: return 'Failed to fetch showtime data.' soup = BeautifulSoup(self.cache) - trs = soup.findAll('tr') + t = soup.find('table', attrs = {'summary': 'Currently Airing'}) + trs = t.tr.td.table.findAll('tr') del trs[0] # delete the "header" table row - # Note: 4th tr contains a hr - for tr1, tr2, tr3 in zip(trs[::4], trs[1::4], trs[2::4]): - title = tr1.td.b.a.text + for tr in trs: + tds = tr.findAll('td') + title = tds[1].text if all([x in title.lower() for x in search]): - eta, channel = [x.strip() for x in tr2('td')[1].text.split('/')] - airtime = tr3('td')[1].text + channel = tds[3].text + airtime = tds[5].text + eta = tds[6].text return '%s airs on %s at %s (eta: %s)' % (title, channel, airtime, eta) return 'No match found.' |