]> jfr.im git - erebus.git/blobdiff - modules/youtube.py
Merge branch 'master' of kronos.jfr.im:erebus
[erebus.git] / modules / youtube.py
index 38b4470f518f55429564127247847858ce7bf4ac..c40bf177a6ee32b8e6f6ac92db307c321b202cff 100644 (file)
@@ -1,10 +1,10 @@
-# Erebus IRC bot - Author: Conny Sjoblom
+# Erebus IRC bot - Author: Erebus Team
 # Youtube URL Checker
 # This file is released into the public domain; see http://unlicense.org/
 
 # module info
 modinfo = {
-       'author': 'Conny Sjoblom',
+       'author': 'Erebus Team',
        'license': 'public domain',
        'compatible': [1], # compatible module API versions
        'depends': [], # other modules required to work properly?
@@ -38,17 +38,19 @@ def privmsg_hook(bot, line):
        if checkfor not in line:
                return # doesn't concern us
 
-       print "Meow"
        for url in url_regex.findall(linetx):
                if checkfor in url:
                        url_data = urlparse.urlparse(url)
                        query = urlparse.parse_qs(url_data.query)
                        video = query["v"][0]
                        api_url = 'http://gdata.youtube.com/feeds/api/videos/%s?alt=json&v=2' % video
-                       respdata = urllib2.urlopen(api_url).read()
-                       video_info = json.loads(respdata)
+                       try:
+                               respdata = urllib2.urlopen(api_url).read()
+                               video_info = json.loads(respdata)
 
-                       title = video_info['entry']['title']["$t"]
-                       author = video_info['entry']['author'][0]['name']['$t']
+                               title = video_info['entry']['title']["$t"]
+                               author = video_info['entry']['author'][0]['name']['$t']
 
-                       bot.msg(line.split()[2], "Youtube: %s (%s)" % (title, author))
+                               bot.msg(line.split()[2], "Youtube: %s (%s)" % (title, author))
+                       except:
+                               pass