master
commit
e791c4ca98
|
@ -15,6 +15,7 @@ from datetime import datetime
|
||||||
|
|
||||||
APIKEY = "b25b959554ed76058ac220b7b2e0a026"
|
APIKEY = "b25b959554ed76058ac220b7b2e0a026"
|
||||||
APIURL = "http://ws.audioscrobbler.com/2.0/?api_key="+APIKEY+"&"
|
APIURL = "http://ws.audioscrobbler.com/2.0/?api_key="+APIKEY+"&"
|
||||||
|
AEPURL = "http://www.davethemoonman.com/lastfm/aep.php?format=txt&username="
|
||||||
|
|
||||||
config = ConfigParser.RawConfigParser()
|
config = ConfigParser.RawConfigParser()
|
||||||
config.optionxform = str
|
config.optionxform = str
|
||||||
|
@ -130,6 +131,38 @@ def now_playing(phenny, input):
|
||||||
|
|
||||||
now_playing.commands = ['np']
|
now_playing.commands = ['np']
|
||||||
|
|
||||||
|
def aep(phenny, input):
|
||||||
|
# c/pied from now_playing, we should but this code in a function
|
||||||
|
# parse input and lookup lastfm user
|
||||||
|
nick = input.nick
|
||||||
|
user = ""
|
||||||
|
arg = input.group(2)
|
||||||
|
if arg == "help":
|
||||||
|
phenny.say("WTF is an AEP? see http://goo.gl/GBbx8")
|
||||||
|
return
|
||||||
|
if not arg or len(arg.strip()) == 0:
|
||||||
|
user = resolve_username(nick) # use the sender
|
||||||
|
if not user: #nick didnt resolve
|
||||||
|
user = nick
|
||||||
|
else: # use the argument
|
||||||
|
user = resolve_username(arg.strip())
|
||||||
|
if not user: # user didnt resolve
|
||||||
|
user = arg
|
||||||
|
user = user.strip()
|
||||||
|
try:
|
||||||
|
req = urlopen("%s%s" % (AEPURL, urlquote(user)))
|
||||||
|
except HTTPError, e:
|
||||||
|
phenny.say("uhoh. try again later, mmkay?")
|
||||||
|
return
|
||||||
|
result = req.read()
|
||||||
|
if "Bad Request" in result:
|
||||||
|
phenny.say("%s doesn't exist on last.fm, perhaps they need to set user (see lastfm-set)" % (user))
|
||||||
|
return
|
||||||
|
aep_val = result.split(":")[1]
|
||||||
|
phenny.say("%s has an AEP of %s" %(user, aep_val))
|
||||||
|
return
|
||||||
|
aep.commands = ['aep']
|
||||||
|
|
||||||
def tasteometer(phenny, input):
|
def tasteometer(phenny, input):
|
||||||
input1 = input.group(2)
|
input1 = input.group(2)
|
||||||
if not input1 or len(input1) == 0:
|
if not input1 or len(input1) == 0:
|
||||||
|
@ -261,4 +294,4 @@ def pretty_date(time=False):
|
||||||
return str(day_diff/365) + " years ago"
|
return str(day_diff/365) + " years ago"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__.strip()
|
print __doc__.strip()
|
||||||
|
|
Loading…
Reference in New Issue