more updates
This commit is contained in:
parent
c124ba7f4d
commit
1dd2c66884
14
index.js
14
index.js
@ -112,6 +112,7 @@ function insertRow(auth) {
|
|||||||
lang: 'en'
|
lang: 'en'
|
||||||
}, function(error, results) {
|
}, function(error, results) {
|
||||||
if ( ! error && results.length > 0 ) {
|
if ( ! error && results.length > 0 ) {
|
||||||
|
console.log(results[0]);
|
||||||
var book = normalizeGoogleData(results[0]);
|
var book = normalizeGoogleData(results[0]);
|
||||||
console.log(book);
|
console.log(book);
|
||||||
appendToSheet(auth, _.values(book));
|
appendToSheet(auth, _.values(book));
|
||||||
@ -126,12 +127,16 @@ function insertRow(auth) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizeGoogleData(book) {
|
function normalizeGoogleData(book) {
|
||||||
var normalized = {
|
return {
|
||||||
title: book.subtitle ? book.title + ': ' + book.subtitle : book.title,
|
title: book.subtitle ? book.title + ': ' + book.subtitle : book.title,
|
||||||
author: _.join(book.authors, ', '),
|
author: _.join(book.authors, ', '),
|
||||||
authorLast: _.lowerCase(_.reverse(_.split(book.authors[0], ' '))[0]),
|
authorLast: _.join(book.authors ? _.lowerCase(_.head(_.reverse(_.split(book.authors[0], ' ')))), '') : '',
|
||||||
"isbn-10": _.find(book.industryIdentifiers, { type: "ISBN_10" }).identifier || '',
|
"isbn-10": _.find(book.industryIdentifiers, { type: "ISBN_10" })
|
||||||
"isbn-13": _.find(book.industryIdentifiers, { type: "ISBN_13" }).identifier || '',
|
? _.find(book.industryIdentifiers, { type: "ISBN_10" }).identifier
|
||||||
|
: '',
|
||||||
|
"isbn-13": _.find(book.industryIdentifiers, { type: "ISBN_13" })
|
||||||
|
? _.find(book.industryIdentifiers, { type: "ISBN_13" }).identifier
|
||||||
|
: '',
|
||||||
format: '',
|
format: '',
|
||||||
genre: book.categories ? book.categories[0] : '',
|
genre: book.categories ? book.categories[0] : '',
|
||||||
publisher: _.trim(book.publisher, '"'),
|
publisher: _.trim(book.publisher, '"'),
|
||||||
@ -143,7 +148,6 @@ function normalizeGoogleData(book) {
|
|||||||
notes: '',
|
notes: '',
|
||||||
signed: ''
|
signed: ''
|
||||||
};
|
};
|
||||||
return normalized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendToSheet(auth, book) {
|
function appendToSheet(auth, book) {
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
"name": "library",
|
"name": "library",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Managing my personal library",
|
"description": "Managing my personal library",
|
||||||
"main": "index.js",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"start": "node ./index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
Loading…
Reference in New Issue
Block a user