From 3564f0bd4376a447b4480b3bdcf4ce7894acffc0 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 9 Oct 2015 16:57:34 -0700 Subject: [PATCH] LastFM: "compare" is dead, remove it. (#36) LastFM seems to have disabled their tasteometer API without any notice whatsoever. Oddly, the only relevant information I can find on this is a Reddit post: https://www.reddit.com/r/lastfm/comments/3mkrqm/is_the_tasteometer_api_down/ --- LastFM/plugin.py | 42 ------------------------------------------ LastFM/test.py | 6 ------ 2 files changed, 48 deletions(-) diff --git a/LastFM/plugin.py b/LastFM/plugin.py index fa1ee37..f8cfa56 100644 --- a/LastFM/plugin.py +++ b/LastFM/plugin.py @@ -312,48 +312,6 @@ class LastFM(callbacks.Plugin): profile = wrap(profile, [optional("something")]) - def compareUsers(self, irc, msg, args, user1, user2): - """ [] - - Compares the music tastes of and . If - is not given, defaults to the LastFM user configured for your - current nick. - """ - if not self.apiKey: - irc.error("The API Key is not set. Please set it via " - "'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) - user2 = (user2 or self.db.get(msg.prefix) or msg.nick) - - channel = msg.args[0] - maxResults = self.registryValue("maxResults", channel) - url = ("%sapi_key=%s&method=tasteometer.compare&type1=user&type2=user" - "&value1=%s&value2=%s&limit=%s" % (self.APIURL, self.apiKey, - user1, user2, maxResults)) - try: - f = utils.web.getUrlFd(url) - except utils.web.Error as e: - irc.error(str(e), Raise=True) - - xml = minidom.parse(f) - resultNode = xml.getElementsByTagName("result")[0] - try: - score = resultNode.getElementsByTagName('score')[0].firstChild.data - score = round(float(score) * 100, 1) - score = ircutils.bold("%s%%" % score) - except (IndexError, ValueError): - score = "unknown" - artists = resultNode.getElementsByTagName("artist") - artistNames = [ircutils.bold(el.getElementsByTagName("name")[0].firstChild.data) - for el in artists] - s = ("Result of comparison between %s and %s: score: %s, common " - "artists: %s" % (ircutils.bold(user1), ircutils.bold(user2), - score, ", ".join(artistNames))) - irc.reply(s) - - compare = wrap(compareUsers, ["something", optional("something")]) - def _formatTimeago(self, unixtime): t = int(time()-unixtime) if t/86400 >= 1: diff --git a/LastFM/test.py b/LastFM/test.py index 069fcdb..289dd73 100644 --- a/LastFM/test.py +++ b/LastFM/test.py @@ -67,12 +67,6 @@ class LastFMTestCase(PluginTestCase): self.assertNotError("profile czshadow") self.assertNotError("profile test") - @unittest.skip("A weird bug in the test system prevents this from " - "working (API key won't set).") - def testCompare(self): - self.assertNotError("compare krf czshadow") - self.assertNotError("compare krf") - def testParseRecentTracks(self): """Parser tests"""