X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/467acacf99ab52ad53af0fc9e95b5be4ca304ea8..2564f20844e0fdd2354f0cb94599eddc93d6e41a:/modules/urls.py diff --git a/modules/urls.py b/modules/urls.py index fbffaf5..9361591 100644 --- a/modules/urls.py +++ b/modules/urls.py @@ -1,4 +1,4 @@ -# 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/ @@ -211,7 +211,10 @@ def goturl(url): 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: @@ -222,7 +225,7 @@ url_regex = ( ) spotify_regex = ( re.compile(r'spotify:(?P\w+):(?P\w{22})'), - re.compile(r'https?://open.spotify.com/(?P\w+)/(?P\w+)') + re.compile(r'https?://open\.spotify\.com/(?P\w+)/(?P\w+)') ) youtube_regex = ( re.compile(r'https?://(?:www\.)?youtube\.com/watch\?[a-zA-Z0-9=&_\-]+'),