From c8823ab66f8622d6f87d942c6a044196b9d162de Mon Sep 17 00:00:00 2001 From: GLolol Date: Mon, 10 Nov 2014 18:49:30 -0800 Subject: [PATCH] LastFM: begin migrating 'lastfm' to API version 2 (still very broken right now) --- plugin.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 1c7e689..280826e 100644 --- a/plugin.py +++ b/plugin.py @@ -108,14 +108,24 @@ class LastFM(callbacks.Plugin): "config plugins.lastfm.apikey and reload the plugin. " "You can sign up for an API Key using " "http://www.last.fm/api/account/create", Raise=True) - + method = method.lower() + knownMethods = {'friends': 'user.getFriends', + 'neighbours': 'user.getNeighbours', + 'profile': 'user.getInfo', + 'recenttracks': 'user.getRecentTracks', + 'tags': 'user.getTopTags', + 'topalbums': 'user.getTopAlbums', + 'topartists': 'user.getTopArtists', + 'toptracks': 'user.getTopTracks'} + if method not in knownMethods: + irc.error("Unsupported method '%s'" % method, Raise=True) id = (optionalId or self.db.getId(msg.nick) or msg.nick) channel = msg.args[0] maxResults = self.registryValue("maxResults", channel) - method = method.lower() - url = "%s/%s/%s.txt" % (self.APIURL_1_0, id, method) - # url = "%sapi_key=%s&method=%s&user=%s" % (self.APIURL_2_0, self.apiKey, method, id) + # url = "%s/%s/%s.txt" % (self.APIURL_1_0, id, method) + url = "%sapi_key=%s&method=%s&user=%s" % (self.APIURL_2_0, + self.apiKey, knownMethods[method], id) try: f = utils.web.getUrlFd(url) except utils.web.Error: