{"action":"created","comment":{"url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/comments/37702705","id":37702705,"diff_hunk":"@@ -134,26 +218,52 @@ def nowPlaying(self, irc, msg, args, optionalId):\n         or specify <id> to switch for one call.\n         \"\"\"\n \n-        id = (optionalId or self.db.getId(msg.nick) or msg.nick)\n+        # check to see if optionalId has been registered with the database\n+        if optionalId:\n+            try:\n+                uid = self.db.getId(optionalId)\n+                if not uid:\n+                    uid = optionalId\n+                    self.log.info(\"LastFM.nowPlaying: [INFO] optionalId not converted, using: %s\" % uid)\n+                else:\n+                    self.log.info(\"LastFM.nowPlaying: [INFO] optionalId converted to LastFM id: %s\" % uid)\n+            except:\n+                uid = optionalId\n+                self.log.info(\"LastFM.nowPlaying: [INFO] optionalId not converted, using: %s\" % uid)\n+        else:\n+            uid = (self.db.getId(msg.nick) or msg.nick)\n+            self.log.info(\"LastFM.nowPlaying: [INFO] optionalId not given, using: %s\" % uid)\n \n         # see http://www.lastfm.de/api/show/user.getrecenttracks\n-        url = \"%s&method=user.getrecenttracks&user=%s\" % (self.APIURL_2_0, id)\n+        # url = \"%s&method=user.getrecenttracks&user=%s\" % (self.APIURL_2_0, id)\n+        url = \"http://www.last.fm/user/%s\" % (uid)\n         try:\n-            f = urllib2.urlopen(url)\n-        except urllib2.HTTPError:\n-            irc.error(\"Unknown ID (%s)\" % id)\n+            f = requests.get(url)\n+        except requests.HTTPError:\n+            irc.reply(\"LastFM: Unknown ID %s\" % uid)","path":"plugin.py","position":140,"original_position":140,"commit_id":"df3a72d57faeb9d7760547258fcc6f8f30fa4188","original_commit_id":"df3a72d57faeb9d7760547258fcc6f8f30fa4188","user":{"login":"GLolol","id":4644601,"avatar_url":"https://avatars.githubusercontent.com/u/4644601?v=3","gravatar_id":"","url":"https://api.github.com/users/GLolol","html_url":"https://github.com/GLolol","followers_url":"https://api.github.com/users/GLolol/followers","following_url":"https://api.github.com/users/GLolol/following{/other_user}","gists_url":"https://api.github.com/users/GLolol/gists{/gist_id}","starred_url":"https://api.github.com/users/GLolol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLolol/subscriptions","organizations_url":"https://api.github.com/users/GLolol/orgs","repos_url":"https://api.github.com/users/GLolol/repos","events_url":"https://api.github.com/users/GLolol/events{/privacy}","received_events_url":"https://api.github.com/users/GLolol/received_events","type":"User","site_admin":false},"body":"All the error configurations for this are per channel options (see `config list reply.error`), which means channel ops can change them to their liking too. Even if it affects other plugins, yo could say that's a good thing because it's more standard that way.","created_at":"2015-08-23T05:36:34Z","updated_at":"2015-08-23T05:36:34Z","html_url":"https://github.com/krf/supybot-lastfm/pull/8#discussion_r37702705","pull_request_url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/comments/37702705"},"html":{"href":"https://github.com/krf/supybot-lastfm/pull/8#discussion_r37702705"},"pull_request":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8","id":43115314,"html_url":"https://github.com/krf/supybot-lastfm/pull/8","diff_url":"https://github.com/krf/supybot-lastfm/pull/8.diff","patch_url":"https://github.com/krf/supybot-lastfm/pull/8.patch","issue_url":"https://api.github.com/repos/krf/supybot-lastfm/issues/8","number":8,"state":"open","locked":false,"title":"Update plugin.py: fix nowPlaying, add YouTube result","user":{"login":"cottongin","id":782294,"avatar_url":"https://avatars.githubusercontent.com/u/782294?v=3","gravatar_id":"","url":"https://api.github.com/users/cottongin","html_url":"https://github.com/cottongin","followers_url":"https://api.github.com/users/cottongin/followers","following_url":"https://api.github.com/users/cottongin/following{/other_user}","gists_url":"https://api.github.com/users/cottongin/gists{/gist_id}","starred_url":"https://api.github.com/users/cottongin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cottongin/subscriptions","organizations_url":"https://api.github.com/users/cottongin/orgs","repos_url":"https://api.github.com/users/cottongin/repos","events_url":"https://api.github.com/users/cottongin/events{/privacy}","received_events_url":"https://api.github.com/users/cottongin/received_events","type":"User","site_admin":false},"body":"Due to LastFM update, lots of API functions are broken. This fixes (more of a band-aid) nowPlaying by scraping user's profile page rather than using API.\r\n\r\nAdds a YouTube link to the end of the reply for the currently playing / last played track.  (Requires YouTube API key, see https://developers.google.com/youtube/registering_an_application)","created_at":"2015-08-23T04:24:52Z","updated_at":"2015-08-23T05:36:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da2e9951af2896fcffe30b4a06f67edf07c524f1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8/commits","review_comments_url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8/comments","review_comment_url":"https://api.github.com/repos/krf/supybot-lastfm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/krf/supybot-lastfm/issues/8/comments","statuses_url":"https://api.github.com/repos/krf/supybot-lastfm/statuses/df3a72d57faeb9d7760547258fcc6f8f30fa4188","head":{"label":"cottongin:patch-1","ref":"patch-1","sha":"df3a72d57faeb9d7760547258fcc6f8f30fa4188","user":{"login":"cottongin","id":782294,"avatar_url":"https://avatars.githubusercontent.com/u/782294?v=3","gravatar_id":"","url":"https://api.github.com/users/cottongin","html_url":"https://github.com/cottongin","followers_url":"https://api.github.com/users/cottongin/followers","following_url":"https://api.github.com/users/cottongin/following{/other_user}","gists_url":"https://api.github.com/users/cottongin/gists{/gist_id}","starred_url":"https://api.github.com/users/cottongin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cottongin/subscriptions","organizations_url":"https://api.github.com/users/cottongin/orgs","repos_url":"https://api.github.com/users/cottongin/repos","events_url":"https://api.github.com/users/cottongin/events{/privacy}","received_events_url":"https://api.github.com/users/cottongin/received_events","type":"User","site_admin":false},"repo":{"id":41235040,"name":"supybot-lastfm","full_name":"cottongin/supybot-lastfm","owner":{"login":"cottongin","id":782294,"avatar_url":"https://avatars.githubusercontent.com/u/782294?v=3","gravatar_id":"","url":"https://api.github.com/users/cottongin","html_url":"https://github.com/cottongin","followers_url":"https://api.github.com/users/cottongin/followers","following_url":"https://api.github.com/users/cottongin/following{/other_user}","gists_url":"https://api.github.com/users/cottongin/gists{/gist_id}","starred_url":"https://api.github.com/users/cottongin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cottongin/subscriptions","organizations_url":"https://api.github.com/users/cottongin/orgs","repos_url":"https://api.github.com/users/cottongin/repos","events_url":"https://api.github.com/users/cottongin/events{/privacy}","received_events_url":"https://api.github.com/users/cottongin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cottongin/supybot-lastfm","description":"Supybot LastFM Plugin","fork":true,"url":"https://api.github.com/repos/cottongin/supybot-lastfm","forks_url":"https://api.github.com/repos/cottongin/supybot-lastfm/forks","keys_url":"https://api.github.com/repos/cottongin/supybot-lastfm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cottongin/supybot-lastfm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cottongin/supybot-lastfm/teams","hooks_url":"https://api.github.com/repos/cottongin/supybot-lastfm/hooks","issue_events_url":"https://api.github.com/repos/cottongin/supybot-lastfm/issues/events{/number}","events_url":"https://api.github.com/repos/cottongin/supybot-lastfm/events","assignees_url":"https://api.github.com/repos/cottongin/supybot-lastfm/assignees{/user}","branches_url":"https://api.github.com/repos/cottongin/supybot-lastfm/branches{/branch}","tags_url":"https://api.github.com/repos/cottongin/supybot-lastfm/tags","blobs_url":"https://api.github.com/repos/cottongin/supybot-lastfm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cottongin/supybot-lastfm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cottongin/supybot-lastfm/git/refs{/sha}","trees_url":"https://api.github.com/repos/cottongin/supybot-lastfm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cottongin/supybot-lastfm/statuses/{sha}","languages_url":"https://api.github.com/repos/cottongin/supybot-lastfm/languages","stargazers_url":"https://api.github.com/repos/cottongin/supybot-lastfm/stargazers","contributors_url":"https://api.github.com/repos/cottongin/supybot-lastfm/contributors","subscribers_url":"https://api.github.com/repos/cottongin/supybot-lastfm/subscribers","subscription_url":"https://api.github.com/repos/cottongin/supybot-lastfm/subscription","commits_url":"https://api.github.com/repos/cottongin/supybot-lastfm/commits{/sha}","git_commits_url":"https://api.github.com/repos/cottongin/supybot-lastfm/git/commits{/sha}","comments_url":"https://api.github.com/repos/cottongin/supybot-lastfm/comments{/number}","issue_comment_url":"https://api.github.com/repos/cottongin/supybot-lastfm/issues/comments{/number}","contents_url":"https://api.github.com/repos/cottongin/supybot-lastfm/contents/{+path}","compare_url":"https://api.github.com/repos/cottongin/supybot-lastfm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cottongin/supybot-lastfm/merges","archive_url":"https://api.github.com/repos/cottongin/supybot-lastfm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cottongin/supybot-lastfm/downloads","issues_url":"https://api.github.com/repos/cottongin/supybot-lastfm/issues{/number}","pulls_url":"https://api.github.com/repos/cottongin/supybot-lastfm/pulls{/number}","milestones_url":"https://api.github.com/repos/cottongin/supybot-lastfm/milestones{/number}","notifications_url":"https://api.github.com/repos/cottongin/supybot-lastfm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cottongin/supybot-lastfm/labels{/name}","releases_url":"https://api.github.com/repos/cottongin/supybot-lastfm/releases{/id}","created_at":"2015-08-23T04:02:28Z","updated_at":"2015-08-23T04:02:28Z","pushed_at":"2015-08-23T04:40:15Z","git_url":"git://github.com/cottongin/supybot-lastfm.git","ssh_url":"git@github.com:cottongin/supybot-lastfm.git","clone_url":"https://github.com/cottongin/supybot-lastfm.git","svn_url":"https://github.com/cottongin/supybot-lastfm","homepage":null,"size":109,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"krf:master","ref":"master","sha":"40fe73e5447fb0c3338d591eacc91f6337463286","user":{"login":"krf","id":30826,"avatar_url":"https://avatars.githubusercontent.com/u/30826?v=3","gravatar_id":"","url":"https://api.github.com/users/krf","html_url":"https://github.com/krf","followers_url":"https://api.github.com/users/krf/followers","following_url":"https://api.github.com/users/krf/following{/other_user}","gists_url":"https://api.github.com/users/krf/gists{/gist_id}","starred_url":"https://api.github.com/users/krf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krf/subscriptions","organizations_url":"https://api.github.com/users/krf/orgs","repos_url":"https://api.github.com/users/krf/repos","events_url":"https://api.github.com/users/krf/events{/privacy}","received_events_url":"https://api.github.com/users/krf/received_events","type":"User","site_admin":false},"repo":{"id":4963516,"name":"supybot-lastfm","full_name":"krf/supybot-lastfm","owner":{"login":"krf","id":30826,"avatar_url":"https://avatars.githubusercontent.com/u/30826?v=3","gravatar_id":"","url":"https://api.github.com/users/krf","html_url":"https://github.com/krf","followers_url":"https://api.github.com/users/krf/followers","following_url":"https://api.github.com/users/krf/following{/other_user}","gists_url":"https://api.github.com/users/krf/gists{/gist_id}","starred_url":"https://api.github.com/users/krf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krf/subscriptions","organizations_url":"https://api.github.com/users/krf/orgs","repos_url":"https://api.github.com/users/krf/repos","events_url":"https://api.github.com/users/krf/events{/privacy}","received_events_url":"https://api.github.com/users/krf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krf/supybot-lastfm","description":"Supybot LastFM Plugin","fork":false,"url":"https://api.github.com/repos/krf/supybot-lastfm","forks_url":"https://api.github.com/repos/krf/supybot-lastfm/forks","keys_url":"https://api.github.com/repos/krf/supybot-lastfm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krf/supybot-lastfm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krf/supybot-lastfm/teams","hooks_url":"https://api.github.com/repos/krf/supybot-lastfm/hooks","issue_events_url":"https://api.github.com/repos/krf/supybot-lastfm/issues/events{/number}","events_url":"https://api.github.com/repos/krf/supybot-lastfm/events","assignees_url":"https://api.github.com/repos/krf/supybot-lastfm/assignees{/user}","branches_url":"https://api.github.com/repos/krf/supybot-lastfm/branches{/branch}","tags_url":"https://api.github.com/repos/krf/supybot-lastfm/tags","blobs_url":"https://api.github.com/repos/krf/supybot-lastfm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krf/supybot-lastfm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krf/supybot-lastfm/git/refs{/sha}","trees_url":"https://api.github.com/repos/krf/supybot-lastfm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krf/supybot-lastfm/statuses/{sha}","languages_url":"https://api.github.com/repos/krf/supybot-lastfm/languages","stargazers_url":"https://api.github.com/repos/krf/supybot-lastfm/stargazers","contributors_url":"https://api.github.com/repos/krf/supybot-lastfm/contributors","subscribers_url":"https://api.github.com/repos/krf/supybot-lastfm/subscribers","subscription_url":"https://api.github.com/repos/krf/supybot-lastfm/subscription","commits_url":"https://api.github.com/repos/krf/supybot-lastfm/commits{/sha}","git_commits_url":"https://api.github.com/repos/krf/supybot-lastfm/git/commits{/sha}","comments_url":"https://api.github.com/repos/krf/supybot-lastfm/comments{/number}","issue_comment_url":"https://api.github.com/repos/krf/supybot-lastfm/issues/comments{/number}","contents_url":"https://api.github.com/repos/krf/supybot-lastfm/contents/{+path}","compare_url":"https://api.github.com/repos/krf/supybot-lastfm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krf/supybot-lastfm/merges","archive_url":"https://api.github.com/repos/krf/supybot-lastfm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krf/supybot-lastfm/downloads","issues_url":"https://api.github.com/repos/krf/supybot-lastfm/issues{/number}","pulls_url":"https://api.github.com/repos/krf/supybot-lastfm/pulls{/number}","milestones_url":"https://api.github.com/repos/krf/supybot-lastfm/milestones{/number}","notifications_url":"https://api.github.com/repos/krf/supybot-lastfm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krf/supybot-lastfm/labels{/name}","releases_url":"https://api.github.com/repos/krf/supybot-lastfm/releases{/id}","created_at":"2012-07-09T19:28:37Z","updated_at":"2015-06-21T00:52:18Z","pushed_at":"2015-08-23T04:40:15Z","git_url":"git://github.com/krf/supybot-lastfm.git","ssh_url":"git@github.com:krf/supybot-lastfm.git","clone_url":"https://github.com/krf/supybot-lastfm.git","svn_url":"https://github.com/krf/supybot-lastfm","homepage":null,"size":176,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8"},"html":{"href":"https://github.com/krf/supybot-lastfm/pull/8"},"issue":{"href":"https://api.github.com/repos/krf/supybot-lastfm/issues/8"},"comments":{"href":"https://api.github.com/repos/krf/supybot-lastfm/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/krf/supybot-lastfm/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/krf/supybot-lastfm/statuses/df3a72d57faeb9d7760547258fcc6f8f30fa4188"}}}}