redownload implemented; spellcheck
This commit is contained in:
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"mobi",
|
||||||
|
"redownload"
|
||||||
|
],
|
||||||
|
"cSpell.ignoreWords": [
|
||||||
|
"csstransforms",
|
||||||
|
"truyen"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# WNtoEmail
|
# WNtoEmail
|
||||||
Node.js script to download new WebNovel chapters convert them to eBook and send to email. Mainly intended for sending to Kindle.
|
Node.js script to download new WebNovel chapters convert them to eBook and send to email. Mainly intended for sending to Kindle.
|
||||||
Script will pack your WebNovels into convinient eBooks, complete with cover image, metadata and table of contents. For ongoing series it will wait for a configured number of new chapters before sending a new volume to avoid spam.
|
Script will pack your WebNovels into convenient eBooks, complete with cover image, metadata and table of contents. For ongoing series it will wait for a configured number of new chapters before sending a new volume to avoid spam.
|
||||||
|
|
||||||
# Dependecies
|
# Dependencies
|
||||||
It's a Node.js project so install that.
|
It's a Node.js project so install that.
|
||||||
Project is using `node-html-parser` and `nodemailer` libraries. It should be enough to:
|
Project is using `node-html-parser` and `nodemailer` libraries. It should be enough to:
|
||||||
```
|
```
|
||||||
@@ -10,6 +10,8 @@ npm install --save node-html-parser
|
|||||||
npm install --save nodemailer
|
npm install --save nodemailer
|
||||||
```
|
```
|
||||||
|
|
||||||
|
https://github.com/vercel/pkg for deploying to binary files.
|
||||||
|
|
||||||
I'm using fetch, which is an experimental feature, it might work differently on different versions. Script written on Node version `v18.4.0`
|
I'm using fetch, which is an experimental feature, it might work differently on different versions. Script written on Node version `v18.4.0`
|
||||||
> ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
|
> ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ OR
|
|||||||
Run the script directly from cloned project with Node.js.
|
Run the script directly from cloned project with Node.js.
|
||||||
|
|
||||||
Intended usage is with a Task Scheduler on Windows. There shouldn't be anything OS specific. Cron on Linux should work after modifying `"converterPath"` to an appropriate command, but that's untested.
|
Intended usage is with a Task Scheduler on Windows. There shouldn't be anything OS specific. Cron on Linux should work after modifying `"converterPath"` to an appropriate command, but that's untested.
|
||||||
At present there is no crash resiliency, if the program crashes for any reason `"lastChapterURL"`, `"lastVolume"` and `"completed"` config will not be cosistent and needs to be corrected. There is a copy of config file created at the start.
|
At present there is no crash resiliency, if the program crashes for any reason `"lastChapterURL"`, `"lastVolume"` and `"completed"` config will not be consistent and needs to be corrected. There is a copy of config file created at the start.
|
||||||
|
|
||||||
## Send to Kindle
|
## Send to Kindle
|
||||||
[Kindle help page](https://www.amazon.com/gp/help/customer/display.html?nodeId=GX9XLEVV8G4DB28H) can help you with setup. You need to assign the divice you want to use an email address (there should already be one with some random ID, you can change it something more convinient) and add your email used for sending to the allowed list.
|
[Kindle help page](https://www.amazon.com/gp/help/customer/display.html?nodeId=GX9XLEVV8G4DB28H) can help you with setup. You need to assign the device you want to use an email address (there should already be one with some random ID, you can change it something more convenient) and add your email used for sending to the allowed list.
|
||||||
|
|||||||
+9
-4
@@ -1,4 +1,3 @@
|
|||||||
//const fs = require('fs');
|
|
||||||
const fs = require('node:fs/promises');
|
const fs = require('node:fs/promises');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const HTMLparser = require('node-html-parser');
|
const HTMLparser = require('node-html-parser');
|
||||||
@@ -39,8 +38,8 @@ function padNumber(num, len) {
|
|||||||
|
|
||||||
function log(text) {
|
function log(text) {
|
||||||
let d = new Date();
|
let d = new Date();
|
||||||
let datetime = `${d.getFullYear()}.${padNumber((d.getMonth() + 1), 2)}.${padNumber(d.getDate(), 2)}_${padNumber(d.getHours(), 2)}:${padNumber(d.getMinutes(), 2)}:${padNumber(d.getSeconds(), 2)}.${padNumber(d.getMilliseconds(), 3)}`;
|
let dateTime = `${d.getFullYear()}.${padNumber((d.getMonth() + 1), 2)}.${padNumber(d.getDate(), 2)}_${padNumber(d.getHours(), 2)}:${padNumber(d.getMinutes(), 2)}:${padNumber(d.getSeconds(), 2)}.${padNumber(d.getMilliseconds(), 3)}`;
|
||||||
fs.appendFile(cleanPath(`./WNtoEmail.log`), `${datetime} ${text}\n`);
|
fs.appendFile(cleanPath(`./WNtoEmail.log`), `${dateTime} ${text}\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mkDir(dirPath) {
|
async function mkDir(dirPath) {
|
||||||
@@ -191,7 +190,7 @@ function sendEbook(subject, ebookAttachments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetch_smth(URL, hosting) {
|
async function fetch_something(URL, hosting) {
|
||||||
let fetchURL = await fetch(URL);
|
let fetchURL = await fetch(URL);
|
||||||
|
|
||||||
if (fetchURL.ok) {
|
if (fetchURL.ok) {
|
||||||
@@ -317,6 +316,12 @@ async function main() {
|
|||||||
let chapters = [];
|
let chapters = [];
|
||||||
let nextChapterURL;
|
let nextChapterURL;
|
||||||
|
|
||||||
|
if (novel['redownload']) {
|
||||||
|
novel['completed'] = false;
|
||||||
|
novel['lastChapterURL'] = false;
|
||||||
|
novel['lastVolume'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!novel['completed']) {
|
if (!novel['completed']) {
|
||||||
let novelInfo = await fetchNovelInfo(novel['novelURL'], 'NF');
|
let novelInfo = await fetchNovelInfo(novel['novelURL'], 'NF');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user