X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/a31511321780ed95989912db819ac124ae1199e9..b13575aa6e013f8f50fba5ae169e871b5cb233dc:/modules/youtube.py diff --git a/modules/youtube.py b/modules/youtube.py index a0c9c9d..cd62f5f 100644 --- a/modules/youtube.py +++ b/modules/youtube.py @@ -1,5 +1,5 @@ # Erebus IRC bot - Author: Conny Sjoblom -# Spotify URL Checker +# Youtube URL Checker # This file is released into the public domain; see http://unlicense.org/ # module info @@ -23,36 +23,10 @@ import HTMLParser from BeautifulSoup import BeautifulSoup checkfor = "youtube" -hostmask_regex = re.compile('^(.*)!(.*)@(.*)$') url_regex = re.compile('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') -def parser_hostmask(hostmask): - if isinstance(hostmask, dict): - return hostmask - - nick = None - user = None - host = None - - if hostmask is not None: - match = hostmask_regex.match(hostmask) - - if not match: - nick = hostmask - else: - nick = match.group(1) - user = match.group(2) - host = match.group(3) - - return { - 'nick': nick, - 'user': user, - 'host': host - } @lib.hooknum("PRIVMSG") def privmsg_hook(bot, line): - sender = parser_hostmask(line[1:line.find(' ')]) - try: linetx = line.split(None, 3)[3][1:] except IndexError: @@ -66,7 +40,4 @@ def privmsg_hook(bot, line): html_parser = HTMLParser.HTMLParser() respdata = urllib2.urlopen(url).read() soup = BeautifulSoup(respdata) - try: - bot.msg(line.split()[2], BeautifulSoup(soup.title.string, convertEntities=BeautifulSoup.HTML_ENTITIES)) - except: - pass + bot.msg(line.split()[2], BeautifulSoup(soup.title.string, convertEntities=BeautifulSoup.HTML_ENTITIES))