{"action":"created","comment":{"url":"https://api.github.com/repos/zotero/translators/pulls/comments/170930330","pull_request_review_id":99689201,"id":170930330,"diff_hunk":"@@ -0,0 +1,709 @@\n+{\n+\t\"translatorID\": \"caa8f42c-9dbf-446e-963b-6ee18e3133d2\",\n+\t\"label\": \"Sveriges radio\",\n+\t\"creator\": \"Sebastian Berlin\",\n+\t\"target\": \"^https?://sverigesradio\\\\.se/sida/artikel.aspx\",\n+\t\"minVersion\": \"3.0\",\n+\t\"maxVersion\": \"\",\n+\t\"priority\": 100,\n+\t\"inRepository\": true,\n+\t\"translatorType\": 4,\n+\t\"browserSupport\": \"gcsibv\",\n+\t\"lastUpdated\": \"2018-02-26 16:34:56\"\n+}\n+\n+/*\n+\t***** BEGIN LICENSE BLOCK *****\n+\n+\tCopyright © 2018 Sebastian Berlin\n+\t\n+\tThis file is part of Zotero.\n+\n+\tZotero is free software: you can redistribute it and/or modify\n+\tit under the terms of the GNU Affero General Public License as published by\n+\tthe Free Software Foundation, either version 3 of the License, or\n+\t(at your option) any later version.\n+\n+\tZotero is distributed in the hope that it will be useful,\n+\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n+\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+\tGNU Affero General Public License for more details.\n+\n+\tYou should have received a copy of the GNU Affero General Public License\n+\talong with Zotero. If not, see <http://www.gnu.org/licenses/>.\n+\n+\t***** END LICENSE BLOCK *****\n+*/\n+\n+\n+// attr()/text() v2\n+function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;}\n+\n+\n+function detectWeb(doc, url) {\n+\t// TODO: adjust the logic here\n+\tif (url.includes('/sida/artikel')) {\n+\t\treturn \"newspaperArticle\";\n+\t} else if (getSearchResults(doc, true)) {\n+\t\treturn \"multiple\";\n+\t}\n+}\n+\n+\n+function getSearchResults(doc, checkOnly) {\n+\tvar items = {};\n+\tvar found = false;\n+\t// TODO: adjust the xpath\n+\tvar rows = doc.querySelectorAll('h2>a.title[href*=\"/article/\"]');\n+\tfor (let i=0; i<rows.length; i++) {\n+\t\t// TODO: check and maybe adjust\n+\t\tlet href = rows[i].href;\n+\t\t// TODO: check and maybe adjust\n+\t\tlet title = ZU.trimInternal(rows[i].textContent);\n+\t\tif (!href || !title) continue;\n+\t\tif (checkOnly) return true;\n+\t\tfound = true;\n+\t\titems[href] = title;\n+\t}\n+\treturn found ? items : false;\n+}\n+\n+\n+function doWeb(doc, url) {\n+\tif (detectWeb(doc, url) == \"multiple\") {\n+\t\tZotero.selectItems(getSearchResults(doc, false), function (items) {\n+\t\t\tif (!items) {\n+\t\t\t\treturn true;\n+\t\t\t}\n+\t\t\tvar articles = [];\n+\t\t\tfor (var i in items) {\n+\t\t\t\tarticles.push(i);\n+\t\t\t}\n+\t\t\tZU.processDocuments(articles, scrape);\n+\t\t});\n+\t} else {\n+\t\tscrape(doc, url);\n+\t}\n+}\n+\n+\n+function scrape(doc, url) {\n+\tvar translator = Zotero.loadTranslator('web');\n+\t// Embedded Metadata\n+\ttranslator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');\n+\t// translator.setDocument(doc);\n+\t\n+\ttranslator.setHandler('itemDone', function (obj, item) {\n+\t\titem.publicationTitle = \"Sveriges Radio\";\n+\n+\t\titem.creators = [];\n+\t\tvar nameNodes = ZU.xpath(doc, '//p[@class=\"byline\"]/text()');\n+\t\tfor(var node of nameNodes) {\n+\t\t\tvar nameString = node.wholeText;\n+\t\t\tif(nameString.trim() === \"\") {\n+\t\t\t\t// Empty text node are added between authors; we want to skip\n+\t\t\t\t// those.\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tvar names = nameString.split(\" \");\n+\t\t\tvar firstName = names[0];\n+\t\t\tvar lastName = names[1];\n+\t\t\tif(lastName === undefined) {\n+\t\t\t\tlastName = \"\";\n+\t\t\t}\n+\t\t\tvar author = {\n+\t\t\t\t// Assume only one first name.\n+\t\t\t\tfirstName: firstName,\n+\t\t\t\tlastName: lastName,\n+\t\t\t\tcreatorType: \"author\"\n+\t\t\t};\n+\t\t\titem.creators.push(author);\n+\t\t}\n+\n+\t\t// The title from the meta is in the format:\n+\t\t// Australierna säger ja till samkönade äktenskap - Nyheter (Ekot)\n+\t\tvar titleString =\n+\t\t\tZU.xpath(doc, '//meta[@name=\"twitter:title\"]')[0]\n+\t\t\t.getAttribute(\"content\");\n+\t\tvar titleParts = titleString.split(\" - \");\n+\t\titem.title = titleParts[0];\n+\t\titem.section = titleParts[1];\n+\n+\t\tvar dateString = \n+\t\t\tZU.xpath(doc, '//meta[@name=\"displaydate\"]')[0]\n+\t\t\t.getAttribute(\"content\");\n+\t\titem.date = dateString.replace(/(....)(..)(..)/, \"$1-$2-$3\");\n+\n+\t\titem.complete();\n+\t});\n+\n+\ttranslator.getTranslatorObject(function(trans) {\n+\t\ttrans.itemType = \"newspaperArticle\";\n+\t\t// TODO map additional meta tags here, or delete completely\n+\t\ttrans.addCustomFields({\n+\t\t\t'twitter:description': 'abstractNote'\n+\t\t});\n+\t\ttrans.doWeb(doc, url);\n+\t});\n+}\n+/** BEGIN TEST CASES **/\n+var testCases = [\n+\t{\n+\t\t\"type\": \"web\",\n+\t\t\"url\": \"https://sverigesradio.se/sida/artikel.aspx?programid=83&artikel=6821850\",\n+\t\t\"items\": [\n+\t\t\t{\n+\t\t\t\t\"itemType\": \"newspaperArticle\",\n+\t\t\t\t\"title\": \"Australierna säger ja till samkönade äktenskap\",\n+\t\t\t\t\"creators\": [\n+\t\t\t\t\t{\n+\t\t\t\t\t\t\"firstName\": \"Ekot\",","path":"Sveriges radio.js","position":160,"original_position":160,"commit_id":"50beabd657d69e587a43873a819f07cda64b8d05","original_commit_id":"50beabd657d69e587a43873a819f07cda64b8d05","user":{"login":"adam3smith","id":128986,"avatar_url":"https://avatars0.githubusercontent.com/u/128986?v=4","gravatar_id":"","url":"https://api.github.com/users/adam3smith","html_url":"https://github.com/adam3smith","followers_url":"https://api.github.com/users/adam3smith/followers","following_url":"https://api.github.com/users/adam3smith/following{/other_user}","gists_url":"https://api.github.com/users/adam3smith/gists{/gist_id}","starred_url":"https://api.github.com/users/adam3smith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam3smith/subscriptions","organizations_url":"https://api.github.com/users/adam3smith/orgs","repos_url":"https://api.github.com/users/adam3smith/repos","events_url":"https://api.github.com/users/adam3smith/events{/privacy}","received_events_url":"https://api.github.com/users/adam3smith/received_events","type":"User","site_admin":false},"body":"using Zotero's built in function will solve this, but the right way to handle single-name and institutional authors is to use `lastName` only and set `fieldMode: true`","created_at":"2018-02-27T14:02:04Z","updated_at":"2018-02-27T14:03:55Z","html_url":"https://github.com/zotero/translators/pull/1567#discussion_r170930330","pull_request_url":"https://api.github.com/repos/zotero/translators/pulls/1567","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments/170930330"},"html":{"href":"https://github.com/zotero/translators/pull/1567#discussion_r170930330"},"pull_request":{"href":"https://api.github.com/repos/zotero/translators/pulls/1567"}}},"pull_request":{"url":"https://api.github.com/repos/zotero/translators/pulls/1567","id":171433968,"html_url":"https://github.com/zotero/translators/pull/1567","diff_url":"https://github.com/zotero/translators/pull/1567.diff","patch_url":"https://github.com/zotero/translators/pull/1567.patch","issue_url":"https://api.github.com/repos/zotero/translators/issues/1567","number":1567,"state":"open","locked":false,"title":"Add translator for sverigesradio.se","user":{"login":"sebastian-berlin-wmse","id":36327337,"avatar_url":"https://avatars0.githubusercontent.com/u/36327337?v=4","gravatar_id":"","url":"https://api.github.com/users/sebastian-berlin-wmse","html_url":"https://github.com/sebastian-berlin-wmse","followers_url":"https://api.github.com/users/sebastian-berlin-wmse/followers","following_url":"https://api.github.com/users/sebastian-berlin-wmse/following{/other_user}","gists_url":"https://api.github.com/users/sebastian-berlin-wmse/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastian-berlin-wmse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastian-berlin-wmse/subscriptions","organizations_url":"https://api.github.com/users/sebastian-berlin-wmse/orgs","repos_url":"https://api.github.com/users/sebastian-berlin-wmse/repos","events_url":"https://api.github.com/users/sebastian-berlin-wmse/events{/privacy}","received_events_url":"https://api.github.com/users/sebastian-berlin-wmse/received_events","type":"User","site_admin":false},"body":"This is the website for the Swedish public service radio.","created_at":"2018-02-26T17:01:53Z","updated_at":"2018-02-27T14:03:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa16d4312860871c207a74ff6e43d0e376b9efaa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/zotero/translators/pulls/1567/commits","review_comments_url":"https://api.github.com/repos/zotero/translators/pulls/1567/comments","review_comment_url":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zotero/translators/issues/1567/comments","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/50beabd657d69e587a43873a819f07cda64b8d05","head":{"label":"Wikimedia-Sverige:master","ref":"master","sha":"50beabd657d69e587a43873a819f07cda64b8d05","user":{"login":"Wikimedia-Sverige","id":8633406,"avatar_url":"https://avatars0.githubusercontent.com/u/8633406?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikimedia-Sverige","html_url":"https://github.com/Wikimedia-Sverige","followers_url":"https://api.github.com/users/Wikimedia-Sverige/followers","following_url":"https://api.github.com/users/Wikimedia-Sverige/following{/other_user}","gists_url":"https://api.github.com/users/Wikimedia-Sverige/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikimedia-Sverige/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikimedia-Sverige/subscriptions","organizations_url":"https://api.github.com/users/Wikimedia-Sverige/orgs","repos_url":"https://api.github.com/users/Wikimedia-Sverige/repos","events_url":"https://api.github.com/users/Wikimedia-Sverige/events{/privacy}","received_events_url":"https://api.github.com/users/Wikimedia-Sverige/received_events","type":"Organization","site_admin":false},"repo":{"id":122999717,"name":"translators","full_name":"Wikimedia-Sverige/translators","owner":{"login":"Wikimedia-Sverige","id":8633406,"avatar_url":"https://avatars0.githubusercontent.com/u/8633406?v=4","gravatar_id":"","url":"https://api.github.com/users/Wikimedia-Sverige","html_url":"https://github.com/Wikimedia-Sverige","followers_url":"https://api.github.com/users/Wikimedia-Sverige/followers","following_url":"https://api.github.com/users/Wikimedia-Sverige/following{/other_user}","gists_url":"https://api.github.com/users/Wikimedia-Sverige/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikimedia-Sverige/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikimedia-Sverige/subscriptions","organizations_url":"https://api.github.com/users/Wikimedia-Sverige/orgs","repos_url":"https://api.github.com/users/Wikimedia-Sverige/repos","events_url":"https://api.github.com/users/Wikimedia-Sverige/events{/privacy}","received_events_url":"https://api.github.com/users/Wikimedia-Sverige/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikimedia-Sverige/translators","description":"Zotero Translators","fork":true,"url":"https://api.github.com/repos/Wikimedia-Sverige/translators","forks_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/forks","keys_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/teams","hooks_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/hooks","issue_events_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/issues/events{/number}","events_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/events","assignees_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/assignees{/user}","branches_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/branches{/branch}","tags_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/tags","blobs_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/languages","stargazers_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/stargazers","contributors_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/contributors","subscribers_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/subscribers","subscription_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/subscription","commits_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/contents/{+path}","compare_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/merges","archive_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/downloads","issues_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/issues{/number}","pulls_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/labels{/name}","releases_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/releases{/id}","deployments_url":"https://api.github.com/repos/Wikimedia-Sverige/translators/deployments","created_at":"2018-02-26T16:52:13Z","updated_at":"2018-02-26T16:52:17Z","pushed_at":"2018-02-26T16:58:12Z","git_url":"git://github.com/Wikimedia-Sverige/translators.git","ssh_url":"git@github.com:Wikimedia-Sverige/translators.git","clone_url":"https://github.com/Wikimedia-Sverige/translators.git","svn_url":"https://github.com/Wikimedia-Sverige/translators","homepage":"http://www.zotero.org/support/dev/translators","size":12846,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zotero:master","ref":"master","sha":"5d0e02a6af8c90e3c9ca4f34a42bb2848c8620a7","user":{"login":"zotero","id":891917,"avatar_url":"https://avatars0.githubusercontent.com/u/891917?v=4","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"repo":{"id":1991863,"name":"translators","full_name":"zotero/translators","owner":{"login":"zotero","id":891917,"avatar_url":"https://avatars0.githubusercontent.com/u/891917?v=4","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zotero/translators","description":"Zotero Translators","fork":false,"url":"https://api.github.com/repos/zotero/translators","forks_url":"https://api.github.com/repos/zotero/translators/forks","keys_url":"https://api.github.com/repos/zotero/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zotero/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zotero/translators/teams","hooks_url":"https://api.github.com/repos/zotero/translators/hooks","issue_events_url":"https://api.github.com/repos/zotero/translators/issues/events{/number}","events_url":"https://api.github.com/repos/zotero/translators/events","assignees_url":"https://api.github.com/repos/zotero/translators/assignees{/user}","branches_url":"https://api.github.com/repos/zotero/translators/branches{/branch}","tags_url":"https://api.github.com/repos/zotero/translators/tags","blobs_url":"https://api.github.com/repos/zotero/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zotero/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zotero/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/zotero/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/zotero/translators/languages","stargazers_url":"https://api.github.com/repos/zotero/translators/stargazers","contributors_url":"https://api.github.com/repos/zotero/translators/contributors","subscribers_url":"https://api.github.com/repos/zotero/translators/subscribers","subscription_url":"https://api.github.com/repos/zotero/translators/subscription","commits_url":"https://api.github.com/repos/zotero/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/zotero/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/zotero/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/zotero/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/zotero/translators/contents/{+path}","compare_url":"https://api.github.com/repos/zotero/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zotero/translators/merges","archive_url":"https://api.github.com/repos/zotero/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zotero/translators/downloads","issues_url":"https://api.github.com/repos/zotero/translators/issues{/number}","pulls_url":"https://api.github.com/repos/zotero/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/zotero/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/zotero/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zotero/translators/labels{/name}","releases_url":"https://api.github.com/repos/zotero/translators/releases{/id}","deployments_url":"https://api.github.com/repos/zotero/translators/deployments","created_at":"2011-07-03T17:40:38Z","updated_at":"2018-02-26T02:20:04Z","pushed_at":"2018-02-27T08:41:45Z","git_url":"git://github.com/zotero/translators.git","ssh_url":"git@github.com:zotero/translators.git","clone_url":"https://github.com/zotero/translators.git","svn_url":"https://github.com/zotero/translators","homepage":"http://www.zotero.org/support/dev/translators","size":12861,"stargazers_count":266,"watchers_count":266,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":222,"mirror_url":null,"archived":false,"open_issues_count":242,"license":null,"forks":222,"open_issues":242,"watchers":266,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/1567"},"html":{"href":"https://github.com/zotero/translators/pull/1567"},"issue":{"href":"https://api.github.com/repos/zotero/translators/issues/1567"},"comments":{"href":"https://api.github.com/repos/zotero/translators/issues/1567/comments"},"review_comments":{"href":"https://api.github.com/repos/zotero/translators/pulls/1567/comments"},"review_comment":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zotero/translators/pulls/1567/commits"},"statuses":{"href":"https://api.github.com/repos/zotero/translators/statuses/50beabd657d69e587a43873a819f07cda64b8d05"}},"author_association":"NONE"}}
{"actor":{"display_login":"adam3smith"}}