X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/24883fd6b9fadd3cf8158b6b7246ee3e9a8d45ad..233f40c362e09bb8e7dda953d51c38409d4fdd5a:/modules/spotify.py diff --git a/modules/spotify.py b/modules/spotify.py index cd5e767..fe4e037 100644 --- a/modules/spotify.py +++ b/modules/spotify.py @@ -1,10 +1,10 @@ -# Erebus IRC bot - Author: John Runyon +# Erebus IRC bot - Author: Conny Sjoblom # Spotify URL Checker # This file is released into the public domain; see http://unlicense.org/ # module info modinfo = { - 'author': 'Conny Sjoblom (BiohZn)', + 'author': 'Conny Sjoblom', 'license': 'public domain', 'compatible': [1], # compatible module API versions 'depends': [], # other modules required to work properly? @@ -18,10 +18,10 @@ modstop = lib.modstop # module code import re -import ctlmod import urllib2 from BeautifulSoup import BeautifulSoup +checkfor = "spotify" hostmask_regex = re.compile('^(.*)!(.*)@(.*)$') spotify_regex = ( re.compile(r'spotify:(?P\w+):(?P\w{22})'), re.compile(r'http://open.spotify.com/(?P\w+)/(?P\w{22})') ) @@ -55,13 +55,16 @@ def privmsg_hook(bot, line): sender = parser_hostmask(line[1:line.find(' ')]) try: - linetx = line.split(' ', 3)[3][1:] + linetx = line.split(None, 3)[3][1:] except IndexError: linetx = '' + if checkfor not in line: + return # doesn't concern us + for r in spotify_regex: for type, track in r.findall(linetx): - url = '%s?uri=spotify:%s:%s' %(spotify_gateway, type, track) + url = '%s?uri=spotify:%s:%s' % (spotify_gateway, type, track) xml = urllib2.urlopen(url).read() soup = BeautifulSoup(xml) lookup_type = soup.contents[2].name