initial commit

This commit is contained in:
Nemo 2020-01-08 02:26:50 +05:30
commit 5a3d84924a
4 changed files with 1075 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

34
index.js Normal file
View File

@ -0,0 +1,34 @@
const AP = require('article-parser');
var nodePandoc = require('node-pandoc-promise');
const url = process.argv[2];
const getArticle = async (url) => {
try {
const article = await AP.extract(url);
return article;
} catch (err) {
console.trace(err);
}
};
getArticle(url).then(res=>{
`
<dc:title id="epub-title-1">${res.title}</dc:title>
<dc:date>${res.published}</dc:date>
<dc:language>en-US</dc:language>
<dc:creator id="epub-creator-1" opf:role="aut">${res.author}</dc:creator>
`
// TODO: Write res.content into a temp file
const imageUrl = res.image
nodePandoc(tmpFile, ['-o', 'filel.epub', '--epbu-cover-image', 'file.png', '--epub-metadata=something.xml'])
.then(res=>{
console.log(res);
}).catch(err=>{
console.error('Oh No: ',err);
});
})

1025
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "url-to-epub",
"version": "1.0.0",
"description": "A single tool to generate a compliant EPUB from a webpage. Zero config. Requires pandoc",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Nemo",
"license": "MIT",
"dependencies": {
"article-parser": "^4.1.1",
"node-pandoc-promise": "0.0.6"
}
}