mirror of
https://github.com/captn3m0/epub-metadata-generator.git
synced 2024-09-13 13:47:26 +00:00
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.
|
||||
|
||||
Currently supports the following:
|
||||
Currently supports the following providers:
|
||||
|
||||
|Provider|Input|
|
||||
|--------|-----|
|
||||
|
2
cli.js
2
cli.js
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
const generator = require('./index');
|
||||
const generator = require("./index");
|
||||
|
||||
let ISBN = process.argv[2];
|
||||
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: "subtitle" }, data.description);
|
||||
contents.ele(
|
||||
"meta",
|
||||
{ refines: "#subtitle", property: "title-type" },
|
||||
"subtitle"
|
||||
);
|
||||
|
||||
if (undefined !== data.description) {
|
||||
contents.ele("dc:title", { id: "subtitle" }, data.description);
|
||||
contents.ele(
|
||||
"meta",
|
||||
{ refines: "#subtitle", property: "title-type" },
|
||||
"subtitle"
|
||||
);
|
||||
}
|
||||
|
||||
contents.ele("dc:language", {}, data.language);
|
||||
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 });
|
||||
return blob;
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ module.exports = {
|
||||
pageCount: book.details.number_of_pages,
|
||||
printType: "BOOK",
|
||||
categories: [],
|
||||
imageLinks: {
|
||||
smallThumbnail: book.thumbnail_url,
|
||||
thumbnail: book.thumbnail_url
|
||||
},
|
||||
imageLinks: {},
|
||||
previewLink: book.preview_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) {
|
||||
standardBook.publisher = book.details.publishers[0];
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user