-
-def gottwitch(url):
- return ""
- #FIXME:
- try:
- linetx = line.split(None, 3)[3][1:]
- except IndexError:
- linetx = ''
-
- if checkfor not in line:
- return # doesn't concern us
-
- for p, h, c in url_regex.findall(linetx):
- if checkfor in h:
- url = 'http://api.justin.tv/api/stream/list.json?channel=%s' % c[1:]
- respdata = urllib2.urlopen(url).read()
- twitch = json.loads(respdata)
- try:
- bot.msg(line.split()[2], 'Twitch: %s (%s playing %s)' % (twitch[0]['channel']['status'], twitch[0]['channel']['login'], twitch[0]['channel']['meta_game']))
- except:
- bot.msg(line.split()[2], 'Twitch: Channel offline.')
-
+def gottwitch(uri):
+ url = 'http://api.justin.tv/api/stream/list.json?channel=%s' % uri.split('/')[0]
+ respdata = urllib2.urlopen(url).read()
+ twitch = json.loads(respdata)
+ try:
+ return 'Twitch: %s (%s playing %s)' % (twitch[0]['channel']['status'], twitch[0]['channel']['login'], twitch[0]['channel']['meta_game'])
+ except:
+ return 'Twitch: Channel offline.'
+
+def goturl(url):
+ soup = BeautifulSoup(urllib2.urlopen(url))
+ return soup.title.string
\ No newline at end of file