Skip to content
Permalink
Browse files

Add Open Library ID to its translator, #wikicite (zotero#1307)

  • Loading branch information...
zuphilip authored and adam3smith committed May 27, 2017
1 parent dfd74f8 commit ead023b66f5f4600585751592d912580261b0833
Showing with 12 additions and 5 deletions.
  1. +12 −5 The Open Library.js
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsbv",
"lastUpdated": "2017-03-17 15:15:57"
"lastUpdated": "2017-05-25 13:52:51"
}

/*
@@ -61,13 +61,15 @@ function getEdition(doc, url){
}

function scrape(doc, url) {
var dcUrl = url.replace(/(OL[A-Z0-9]+)\/.+/, "$1.rdf");
var regex = /(OL[A-Z0-9]+)\/.+/;
var dcUrl = url.replace(regex, "$1.rdf");
var olid = url.match(regex);

//no ISBN in the RDF data; scraping that from the page; sigh.
var isbnscrape;
if (ZU.xpathText(doc, '//td[@class="title" and span[contains(text(), "ISBN 13")]]') ){
isbnscrape = ZU.xpathText(doc, '//td[@class="title" and span[contains(text(), "ISBN 13")]]/following-sibling::td');
}
else{
} else {
isbnscrape = ZU.xpathText(doc, '//td[@class="title" and span[contains(text(), "ISBN 10")]]/following-sibling::td');
}
Zotero.Utilities.doGet(dcUrl, function (text) {
@@ -106,6 +108,9 @@ function scrape(doc, url) {
if (numPages) item.numPages = numPages.replace(/p\..*/, "");
if (note) item.notes.push(note);
if (item.extra) item.abstractNote=item.extra; item.extra="";
if (olid) {
item.extra = "Open Library ID: " + olid[1];
}
item.place = place;
if (isbn) item.ISBN= isbn;
else item.ISBN = isbnscrape;
@@ -173,6 +178,7 @@ var testCases = [
],
"date": "April 3, 1985",
"ISBN": "9782213014012",
"extra": "Open Library ID: OL12455445M",
"libraryCatalog": "The Open Library",
"numPages": "486",
"publisher": "Fayard",
@@ -199,6 +205,7 @@ var testCases = [
],
"date": "1985",
"ISBN": "9788402103222",
"extra": "Open Library ID: OL13188011M",
"libraryCatalog": "The Open Library",
"publisher": "Bruguera",
"shortTitle": "Borges",
@@ -210,4 +217,4 @@ var testCases = [
]
}
]
/** END TEST CASES **/
/** END TEST CASES **/

0 comments on commit ead023b

Please sign in to comment.
You can’t perform that action at this time.