more updates

This commit is contained in:
David 2017-05-15 21:46:41 -04:00
parent c124ba7f4d
commit 1dd2c66884
2 changed files with 12 additions and 9 deletions

View File

@ -112,6 +112,7 @@ function insertRow(auth) {
lang: 'en'
}, function(error, results) {
if ( ! error && results.length > 0 ) {
console.log(results[0]);
var book = normalizeGoogleData(results[0]);
console.log(book);
appendToSheet(auth, _.values(book));
@ -126,12 +127,16 @@ function insertRow(auth) {
}
function normalizeGoogleData(book) {
var normalized = {
return {
title: book.subtitle ? book.title + ': ' + book.subtitle : book.title,
author: _.join(book.authors, ', '),
authorLast: _.lowerCase(_.reverse(_.split(book.authors[0], ' '))[0]),
"isbn-10": _.find(book.industryIdentifiers, { type: "ISBN_10" }).identifier || '',
"isbn-13": _.find(book.industryIdentifiers, { type: "ISBN_13" }).identifier || '',
authorLast: _.join(book.authors ? _.lowerCase(_.head(_.reverse(_.split(book.authors[0], ' ')))), '') : '',
"isbn-10": _.find(book.industryIdentifiers, { type: "ISBN_10" })
? _.find(book.industryIdentifiers, { type: "ISBN_10" }).identifier
: '',
"isbn-13": _.find(book.industryIdentifiers, { type: "ISBN_13" })
? _.find(book.industryIdentifiers, { type: "ISBN_13" }).identifier
: '',
format: '',
genre: book.categories ? book.categories[0] : '',
publisher: _.trim(book.publisher, '"'),
@ -143,7 +148,6 @@ function normalizeGoogleData(book) {
notes: '',
signed: ''
};
return normalized;
}
function appendToSheet(auth, book) {

View File

@ -2,9 +2,8 @@
"name": "library",
"version": "1.0.0",
"description": "Managing my personal library",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node ./index.js"
},
"repository": {
"type": "git",