-# Erebus IRC bot - Author: Erebus Team
+# Erebus IRC bot - Author: Conny Sjoblom
# vim: fileencoding=utf-8
# URL Checker
# This file is released into the public domain; see http://unlicense.org/
opener = urllib2.build_opener(SmartRedirectHandler())
try:
soup = BeautifulSoup(opener.open(request, timeout=0.5))
- return unescape('%s' % (soup.title.string))
+ if soup.title:
+ return unescape('%s' % (soup.title.string))
+ else:
+ return None
except urllib2.HTTPError as e:
return 'Error: %s %s' % (e.code, e.reason)
except Exception as e:
)
spotify_regex = (
re.compile(r'spotify:(?P<type>\w+):(?P<track_id>\w{22})'),
- re.compile(r'https?://open.spotify.com/(?P<type>\w+)/(?P<track_id>\w+)')
+ re.compile(r'https?://open\.spotify\.com/(?P<type>\w+)/(?P<track_id>\w+)')
)
youtube_regex = (
re.compile(r'https?://(?:www\.)?youtube\.com/watch\?[a-zA-Z0-9=&_\-]+'),