Fixes date and cover
This commit is contained in:
parent
46197365d0
commit
85c9ef2ed6
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Generates a `metadata.xml` file for an EPUB from various online sources, given a few identifiers.
|
Generates a `metadata.xml` file for an EPUB from various online sources, given a few identifiers.
|
||||||
|
|
||||||
Currently supports the following:
|
Currently supports the following providers:
|
||||||
|
|
||||||
|Provider|Input|
|
|Provider|Input|
|
||||||
|--------|-----|
|
|--------|-----|
|
||||||
|
|
2
cli.js
2
cli.js
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const generator = require('./index');
|
const generator = require("./index");
|
||||||
|
|
||||||
let ISBN = process.argv[2];
|
let ISBN = process.argv[2];
|
||||||
let filepath = process.argv[3];
|
let filepath = process.argv[3];
|
||||||
|
|
36
index.js
36
index.js
|
@ -20,16 +20,40 @@ function _convert(data, pretty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
contents.ele("dc:title", { id: "title" }, data.title);
|
contents.ele("dc:title", { id: "title" }, data.title);
|
||||||
contents.ele("dc:title", { id: "subtitle" }, data.description);
|
|
||||||
contents.ele(
|
if (undefined !== data.description) {
|
||||||
"meta",
|
contents.ele("dc:title", { id: "subtitle" }, data.description);
|
||||||
{ refines: "#subtitle", property: "title-type" },
|
contents.ele(
|
||||||
"subtitle"
|
"meta",
|
||||||
);
|
{ refines: "#subtitle", property: "title-type" },
|
||||||
|
"subtitle"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
contents.ele("dc:language", {}, data.language);
|
contents.ele("dc:language", {}, data.language);
|
||||||
contents.ele("dc:publisher", {}, data.publisher);
|
contents.ele("dc:publisher", {}, data.publisher);
|
||||||
|
|
||||||
|
let date = new Date(Date.parse(data.publishedDate));
|
||||||
|
|
||||||
|
function pad(number) {
|
||||||
|
if (number < 10) {
|
||||||
|
return "0" + number;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
let epubDate =
|
||||||
|
date.getUTCFullYear() +
|
||||||
|
"-" +
|
||||||
|
pad(date.getUTCMonth() + 1) +
|
||||||
|
"-" +
|
||||||
|
pad(date.getUTCDate());
|
||||||
|
|
||||||
|
contents.ele("dc:date", {}, epubDate);
|
||||||
|
if (undefined !== data.imageLinks.cover) {
|
||||||
|
contents.ele("dc:identifier", { id: "cover-url" }, data.imageLinks.cover);
|
||||||
|
}
|
||||||
|
|
||||||
let blob = contents.end({ pretty: pretty });
|
let blob = contents.end({ pretty: pretty });
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,7 @@ module.exports = {
|
||||||
pageCount: book.details.number_of_pages,
|
pageCount: book.details.number_of_pages,
|
||||||
printType: "BOOK",
|
printType: "BOOK",
|
||||||
categories: [],
|
categories: [],
|
||||||
imageLinks: {
|
imageLinks: {},
|
||||||
smallThumbnail: book.thumbnail_url,
|
|
||||||
thumbnail: book.thumbnail_url
|
|
||||||
},
|
|
||||||
previewLink: book.preview_url,
|
previewLink: book.preview_url,
|
||||||
infoLink: book.info_url
|
infoLink: book.info_url
|
||||||
};
|
};
|
||||||
|
@ -51,6 +48,20 @@ module.exports = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (undefined !== book.details.cover) {
|
||||||
|
if (undefined !== book.details.cover.small) {
|
||||||
|
standardBook.imageLinks.smallThumbnail = book.details.cover.small;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (undefined !== book.details.cover.large) {
|
||||||
|
standardBook.imageLinks.cover = book.details.cover.large;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (undefined !== book.details.cover.medium) {
|
||||||
|
standardBook.imageLinks.thumnail = book.details.cover.medium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (book.details.publishers) {
|
if (book.details.publishers) {
|
||||||
standardBook.publisher = book.details.publishers[0];
|
standardBook.publisher = book.details.publishers[0];
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue