{"action":"created","comment":{"url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/comments/71179512","id":71179512,"diff_hunk":"@@ -0,0 +1,36 @@\n+import requests\n+import ujson\n+\n+def get_messybrainz_id(querydata):\n+    \"\"\"\n+    This function queries messybrainz to get a msid according to the 'artist/title' present in the item metadata\n+    Args:\n+        querydata: A dictionary containing at least artis and song title\n+\n+    Returns:\n+        msid: string messybrainz id -> if it is found in the messybrainz database\n+        None: if no reference is fount in messybrainz database\n+\n+    \"\"\"\n+    msurl = 'https://messybrainz.org/submit'\n+    if isinstance(querydata, list):\n+        if 'artist' in querydata[0].keys() and 'title' in querydata[0].keys():\n+            jsondata = ujson.dumps(querydata)\n+            r = requests.post(msurl, data=jsondata)\n+            if r.status_code == 200:\n+                #get the correct id\n+                responsedata = r.json()\n+                if 'recording_mbid' in responsedata['payload'][0]['ids'].keys() and 'recording_msid' in responsedata['payload'][0]['ids'].keys():","path":"webserver/external/messybrainz.py","position":23,"original_position":23,"commit_id":"87db242a362e309415bc454fed49cbaa615596c8","original_commit_id":"87db242a362e309415bc454fed49cbaa615596c8","user":{"login":"alastair","id":19217,"avatar_url":"https://avatars.githubusercontent.com/u/19217?v=3","gravatar_id":"","url":"https://api.github.com/users/alastair","html_url":"https://github.com/alastair","followers_url":"https://api.github.com/users/alastair/followers","following_url":"https://api.github.com/users/alastair/following{/other_user}","gists_url":"https://api.github.com/users/alastair/gists{/gist_id}","starred_url":"https://api.github.com/users/alastair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alastair/subscriptions","organizations_url":"https://api.github.com/users/alastair/orgs","repos_url":"https://api.github.com/users/alastair/repos","events_url":"https://api.github.com/users/alastair/events{/privacy}","received_events_url":"https://api.github.com/users/alastair/received_events","type":"User","site_admin":false},"body":"in a case like this, where you are always accessing the same data in an object, it's a good idea to create a temporary variable to store it:\r\n```python\r\ndata = responsedata['payload'][0]['ids']\r\nif 'recording_mbid' in data and 'recording_msid' in data:  # note that if you use 'in' with a dictionary you don't need 'keys'","created_at":"2016-07-18T16:22:38Z","updated_at":"2016-07-18T16:22:38Z","html_url":"https://github.com/metabrainz/acousticbrainz-server/pull/189#discussion_r71179512","pull_request_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189","_links":{"self":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/comments/71179512"},"html":{"href":"https://github.com/metabrainz/acousticbrainz-server/pull/189#discussion_r71179512"},"pull_request":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189"}}},"pull_request":{"url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189","id":71028066,"html_url":"https://github.com/metabrainz/acousticbrainz-server/pull/189","diff_url":"https://github.com/metabrainz/acousticbrainz-server/pull/189.diff","patch_url":"https://github.com/metabrainz/acousticbrainz-server/pull/189.patch","issue_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/189","number":189,"state":"open","locked":false,"title":"Dataset Items check","user":{"login":"hellska","id":4158984,"avatar_url":"https://avatars.githubusercontent.com/u/4158984?v=3","gravatar_id":"","url":"https://api.github.com/users/hellska","html_url":"https://github.com/hellska","followers_url":"https://api.github.com/users/hellska/followers","following_url":"https://api.github.com/users/hellska/following{/other_user}","gists_url":"https://api.github.com/users/hellska/gists{/gist_id}","starred_url":"https://api.github.com/users/hellska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellska/subscriptions","organizations_url":"https://api.github.com/users/hellska/orgs","repos_url":"https://api.github.com/users/hellska/repos","events_url":"https://api.github.com/users/hellska/events{/privacy}","received_events_url":"https://api.github.com/users/hellska/received_events","type":"User","site_admin":false},"body":"Added a function to check for low-level data duplicates\r\nAdded a skeleton for a function that generates uuids\r\nAdded the tests for the two functions\r\nModified the SANITY_CHECK_KEYS","created_at":"2016-05-23T09:15:09Z","updated_at":"2016-07-18T16:22:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05e2fcb47cad8811816012d302d8fa0c1fc66c2c","assignee":{"login":"gentlecat","id":460525,"avatar_url":"https://avatars.githubusercontent.com/u/460525?v=3","gravatar_id":"","url":"https://api.github.com/users/gentlecat","html_url":"https://github.com/gentlecat","followers_url":"https://api.github.com/users/gentlecat/followers","following_url":"https://api.github.com/users/gentlecat/following{/other_user}","gists_url":"https://api.github.com/users/gentlecat/gists{/gist_id}","starred_url":"https://api.github.com/users/gentlecat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentlecat/subscriptions","organizations_url":"https://api.github.com/users/gentlecat/orgs","repos_url":"https://api.github.com/users/gentlecat/repos","events_url":"https://api.github.com/users/gentlecat/events{/privacy}","received_events_url":"https://api.github.com/users/gentlecat/received_events","type":"User","site_admin":false},"assignees":[{"login":"gentlecat","id":460525,"avatar_url":"https://avatars.githubusercontent.com/u/460525?v=3","gravatar_id":"","url":"https://api.github.com/users/gentlecat","html_url":"https://github.com/gentlecat","followers_url":"https://api.github.com/users/gentlecat/followers","following_url":"https://api.github.com/users/gentlecat/following{/other_user}","gists_url":"https://api.github.com/users/gentlecat/gists{/gist_id}","starred_url":"https://api.github.com/users/gentlecat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gentlecat/subscriptions","organizations_url":"https://api.github.com/users/gentlecat/orgs","repos_url":"https://api.github.com/users/gentlecat/repos","events_url":"https://api.github.com/users/gentlecat/events{/privacy}","received_events_url":"https://api.github.com/users/gentlecat/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189/commits","review_comments_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189/comments","review_comment_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/189/comments","statuses_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/statuses/87db242a362e309415bc454fed49cbaa615596c8","head":{"label":"hellska:dataset_creation_toolkit","ref":"dataset_creation_toolkit","sha":"87db242a362e309415bc454fed49cbaa615596c8","user":{"login":"hellska","id":4158984,"avatar_url":"https://avatars.githubusercontent.com/u/4158984?v=3","gravatar_id":"","url":"https://api.github.com/users/hellska","html_url":"https://github.com/hellska","followers_url":"https://api.github.com/users/hellska/followers","following_url":"https://api.github.com/users/hellska/following{/other_user}","gists_url":"https://api.github.com/users/hellska/gists{/gist_id}","starred_url":"https://api.github.com/users/hellska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellska/subscriptions","organizations_url":"https://api.github.com/users/hellska/orgs","repos_url":"https://api.github.com/users/hellska/repos","events_url":"https://api.github.com/users/hellska/events{/privacy}","received_events_url":"https://api.github.com/users/hellska/received_events","type":"User","site_admin":false},"repo":{"id":59016171,"name":"acousticbrainz-server","full_name":"hellska/acousticbrainz-server","owner":{"login":"hellska","id":4158984,"avatar_url":"https://avatars.githubusercontent.com/u/4158984?v=3","gravatar_id":"","url":"https://api.github.com/users/hellska","html_url":"https://github.com/hellska","followers_url":"https://api.github.com/users/hellska/followers","following_url":"https://api.github.com/users/hellska/following{/other_user}","gists_url":"https://api.github.com/users/hellska/gists{/gist_id}","starred_url":"https://api.github.com/users/hellska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellska/subscriptions","organizations_url":"https://api.github.com/users/hellska/orgs","repos_url":"https://api.github.com/users/hellska/repos","events_url":"https://api.github.com/users/hellska/events{/privacy}","received_events_url":"https://api.github.com/users/hellska/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hellska/acousticbrainz-server","description":"The server components for the AcousticBrainz project","fork":true,"url":"https://api.github.com/repos/hellska/acousticbrainz-server","forks_url":"https://api.github.com/repos/hellska/acousticbrainz-server/forks","keys_url":"https://api.github.com/repos/hellska/acousticbrainz-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hellska/acousticbrainz-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hellska/acousticbrainz-server/teams","hooks_url":"https://api.github.com/repos/hellska/acousticbrainz-server/hooks","issue_events_url":"https://api.github.com/repos/hellska/acousticbrainz-server/issues/events{/number}","events_url":"https://api.github.com/repos/hellska/acousticbrainz-server/events","assignees_url":"https://api.github.com/repos/hellska/acousticbrainz-server/assignees{/user}","branches_url":"https://api.github.com/repos/hellska/acousticbrainz-server/branches{/branch}","tags_url":"https://api.github.com/repos/hellska/acousticbrainz-server/tags","blobs_url":"https://api.github.com/repos/hellska/acousticbrainz-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hellska/acousticbrainz-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hellska/acousticbrainz-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/hellska/acousticbrainz-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hellska/acousticbrainz-server/statuses/{sha}","languages_url":"https://api.github.com/repos/hellska/acousticbrainz-server/languages","stargazers_url":"https://api.github.com/repos/hellska/acousticbrainz-server/stargazers","contributors_url":"https://api.github.com/repos/hellska/acousticbrainz-server/contributors","subscribers_url":"https://api.github.com/repos/hellska/acousticbrainz-server/subscribers","subscription_url":"https://api.github.com/repos/hellska/acousticbrainz-server/subscription","commits_url":"https://api.github.com/repos/hellska/acousticbrainz-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/hellska/acousticbrainz-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/hellska/acousticbrainz-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/hellska/acousticbrainz-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/hellska/acousticbrainz-server/contents/{+path}","compare_url":"https://api.github.com/repos/hellska/acousticbrainz-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hellska/acousticbrainz-server/merges","archive_url":"https://api.github.com/repos/hellska/acousticbrainz-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hellska/acousticbrainz-server/downloads","issues_url":"https://api.github.com/repos/hellska/acousticbrainz-server/issues{/number}","pulls_url":"https://api.github.com/repos/hellska/acousticbrainz-server/pulls{/number}","milestones_url":"https://api.github.com/repos/hellska/acousticbrainz-server/milestones{/number}","notifications_url":"https://api.github.com/repos/hellska/acousticbrainz-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hellska/acousticbrainz-server/labels{/name}","releases_url":"https://api.github.com/repos/hellska/acousticbrainz-server/releases{/id}","deployments_url":"https://api.github.com/repos/hellska/acousticbrainz-server/deployments","created_at":"2016-05-17T11:22:50Z","updated_at":"2016-05-17T11:22:51Z","pushed_at":"2016-07-18T14:53:40Z","git_url":"git://github.com/hellska/acousticbrainz-server.git","ssh_url":"git@github.com:hellska/acousticbrainz-server.git","clone_url":"https://github.com/hellska/acousticbrainz-server.git","svn_url":"https://github.com/hellska/acousticbrainz-server","homepage":"https://acousticbrainz.org/","size":2277,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"metabrainz:master","ref":"master","sha":"5897788d60f0feb4dfa99ac2810e09ed954c006f","user":{"login":"metabrainz","id":293421,"avatar_url":"https://avatars.githubusercontent.com/u/293421?v=3","gravatar_id":"","url":"https://api.github.com/users/metabrainz","html_url":"https://github.com/metabrainz","followers_url":"https://api.github.com/users/metabrainz/followers","following_url":"https://api.github.com/users/metabrainz/following{/other_user}","gists_url":"https://api.github.com/users/metabrainz/gists{/gist_id}","starred_url":"https://api.github.com/users/metabrainz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabrainz/subscriptions","organizations_url":"https://api.github.com/users/metabrainz/orgs","repos_url":"https://api.github.com/users/metabrainz/repos","events_url":"https://api.github.com/users/metabrainz/events{/privacy}","received_events_url":"https://api.github.com/users/metabrainz/received_events","type":"Organization","site_admin":false},"repo":{"id":24893738,"name":"acousticbrainz-server","full_name":"metabrainz/acousticbrainz-server","owner":{"login":"metabrainz","id":293421,"avatar_url":"https://avatars.githubusercontent.com/u/293421?v=3","gravatar_id":"","url":"https://api.github.com/users/metabrainz","html_url":"https://github.com/metabrainz","followers_url":"https://api.github.com/users/metabrainz/followers","following_url":"https://api.github.com/users/metabrainz/following{/other_user}","gists_url":"https://api.github.com/users/metabrainz/gists{/gist_id}","starred_url":"https://api.github.com/users/metabrainz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metabrainz/subscriptions","organizations_url":"https://api.github.com/users/metabrainz/orgs","repos_url":"https://api.github.com/users/metabrainz/repos","events_url":"https://api.github.com/users/metabrainz/events{/privacy}","received_events_url":"https://api.github.com/users/metabrainz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metabrainz/acousticbrainz-server","description":"The server components for the AcousticBrainz project","fork":false,"url":"https://api.github.com/repos/metabrainz/acousticbrainz-server","forks_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/forks","keys_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/teams","hooks_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/hooks","issue_events_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/events{/number}","events_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/events","assignees_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/assignees{/user}","branches_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/branches{/branch}","tags_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/tags","blobs_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/statuses/{sha}","languages_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/languages","stargazers_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/stargazers","contributors_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/contributors","subscribers_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/subscribers","subscription_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/subscription","commits_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/contents/{+path}","compare_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/merges","archive_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/downloads","issues_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues{/number}","pulls_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls{/number}","milestones_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/milestones{/number}","notifications_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/labels{/name}","releases_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/releases{/id}","deployments_url":"https://api.github.com/repos/metabrainz/acousticbrainz-server/deployments","created_at":"2014-10-07T14:22:44Z","updated_at":"2016-06-20T18:30:00Z","pushed_at":"2016-07-18T14:53:41Z","git_url":"git://github.com/metabrainz/acousticbrainz-server.git","ssh_url":"git@github.com:metabrainz/acousticbrainz-server.git","clone_url":"https://github.com/metabrainz/acousticbrainz-server.git","svn_url":"https://github.com/metabrainz/acousticbrainz-server","homepage":"https://acousticbrainz.org/","size":2369,"stargazers_count":36,"watchers_count":36,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":22,"forks":18,"open_issues":22,"watchers":36,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189"},"html":{"href":"https://github.com/metabrainz/acousticbrainz-server/pull/189"},"issue":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/189"},"comments":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/issues/189/comments"},"review_comments":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189/comments"},"review_comment":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/pulls/189/commits"},"statuses":{"href":"https://api.github.com/repos/metabrainz/acousticbrainz-server/statuses/87db242a362e309415bc454fed49cbaa615596c8"}}}}
{"actor":{"display_login":"alastair"}}