From fd0f23b7762f7531fcf2e8698e2b5a9af0eacd2e Mon Sep 17 00:00:00 2001 From: Zjamnik Date: Thu, 26 Mar 2026 09:34:58 +0100 Subject: [PATCH] all pending changes from working copy --- WNtoEmail.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/WNtoEmail.js b/WNtoEmail.js index 6dede5d..9beeaea 100644 --- a/WNtoEmail.js +++ b/WNtoEmail.js @@ -49,7 +49,7 @@ async function mkDir(dirPath) { await fs.access(cleanPath(dirPath)); } catch (err) { - await fs.mkdir(dirPath, { recursive: true }); + await fs.mkdir(cleanPath(dirPath), { recursive: true }); } await fs.access(cleanPath(dirPath)); } @@ -70,7 +70,7 @@ async function readFile(file, { format = 'utf8' } = {}) { async function loadConfig() { let novelConfigDefault = { "downloadLocation": "", - "converterPath": "ebook-convert.exe", + "converterPath": "D:/Calibre/Calibre/ebook-convert.exe", "ebookFormat": "epub", "sendEmail": false, "copyPath": "", @@ -84,6 +84,7 @@ async function loadConfig() { "NF": "https://novelfull.com/", "TNC": "https://thatnovelcorner.com/ external source, use with sendOnly = true", "BBB": "https://bluebellsinbloom.wordpress.com/", + "JN": "https://jnovels.com/ external" }, "template": { "novelURL": "", @@ -285,9 +286,17 @@ async function getNovelInfo(response, hosting) { info = [title, author, completed, 'https://novelfull.com' + firstChapterURL, 'https://novelfull.com' + coverURL]; break; + case 'JN': + html.querySelectorAll('.post-content ol li').forEach(elem => { + if (elem.innerText.match('V|volume')) { + info = elem.innerText.match(/\d+/)[0]; + } + }); + break; + case 'TNC': html.querySelectorAll('a').forEach(elem => { - if (elem.innerText.match('Volume')) { + if (elem.innerText.match('V|volume')) { info = elem.innerText.match(/\d+/)[0]; } }); @@ -325,7 +334,7 @@ function getChapterContent(response, hosting) { switch (hosting) { case 'NF': - chapterContent += '

' + html.querySelector('span.chapter-text').innerText + '

'; + chapterContent += '

' + html.querySelector('span.chapter-text').innerText + '

'; html.querySelectorAll('div#chapter-content p').forEach(element => { chapterContent += element.outerHTML; @@ -345,7 +354,7 @@ async function clearLog() { async function main() { await loadConfig(); - await clearLog() + await clearLog(); for (let i = 0; i < config['novels'].length; ++i) { let novel = clone(config['novels'][i]); @@ -370,7 +379,7 @@ async function main() { const novelPath = `${config.downloadLocation}/${novel.title}`; const novelVolumeRegex = new RegExp(novel.sendOnlyRegex + '.' + novel.sendOnlyFormat); - let lastVolumeOnline = parseInt(await fetchNovelInfo(novel['novelURL'], 'TNC')); + let lastVolumeOnline = parseInt(await fetchNovelInfo(novel['novelURL'], novel.hosting)); if (lastVolumeOnline > novel.lastVolume) { log(`New volume found online: ${novel.title} ${lastVolumeOnline} ${novel.novelURL}`); @@ -419,7 +428,7 @@ async function main() { async function downloadChaptersFunction(novel, i) { let chapters = []; let nextChapterURL; - let novelInfo = await fetchNovelInfo(novel['novelURL'], 'NF'); + let novelInfo = await fetchNovelInfo(novel['novelURL'], novel.hosting); novel['title'] = novelInfo[0]; novel['author'] = novelInfo[1]; @@ -432,19 +441,19 @@ async function main() { if (!novel['lastChapterURL']) { novel['lastChapterURL'] = novelInfo[3]; - let chapter = await fetchChapter(novelInfo[3], 'NF'); + let chapter = await fetchChapter(novelInfo[3], novel.hosting); log('Downloaded chapter: ' + chapters.length + ' ' + novelInfo[3]); chapters.push(chapter); } let novelDir = `${config['downloadLocation']}/${novel['title']}`; - const nextChapterURLtemp = await fetchChapter(novel['lastChapterURL'], 'NF'); + const nextChapterURLtemp = await fetchChapter(novel['lastChapterURL'], novel.hosting); nextChapterURL = nextChapterURLtemp[1]; while (nextChapterURL) { novel['lastChapterURL'] = nextChapterURL; - let chapter = await fetchChapter(nextChapterURL, 'NF'); + let chapter = await fetchChapter(nextChapterURL, novel.hosting); log('Downloaded chapter: ' + chapters.length + ' ' + nextChapterURL); chapters.push(chapter); nextChapterURL = chapter[1];