all pending changes from working copy
This commit is contained in:
+19
-10
@@ -49,7 +49,7 @@ async function mkDir(dirPath) {
|
|||||||
await fs.access(cleanPath(dirPath));
|
await fs.access(cleanPath(dirPath));
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
await fs.mkdir(dirPath, { recursive: true });
|
await fs.mkdir(cleanPath(dirPath), { recursive: true });
|
||||||
}
|
}
|
||||||
await fs.access(cleanPath(dirPath));
|
await fs.access(cleanPath(dirPath));
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ async function readFile(file, { format = 'utf8' } = {}) {
|
|||||||
async function loadConfig() {
|
async function loadConfig() {
|
||||||
let novelConfigDefault = {
|
let novelConfigDefault = {
|
||||||
"downloadLocation": "",
|
"downloadLocation": "",
|
||||||
"converterPath": "ebook-convert.exe",
|
"converterPath": "D:/Calibre/Calibre/ebook-convert.exe",
|
||||||
"ebookFormat": "epub",
|
"ebookFormat": "epub",
|
||||||
"sendEmail": false,
|
"sendEmail": false,
|
||||||
"copyPath": "",
|
"copyPath": "",
|
||||||
@@ -84,6 +84,7 @@ async function loadConfig() {
|
|||||||
"NF": "https://novelfull.com/",
|
"NF": "https://novelfull.com/",
|
||||||
"TNC": "https://thatnovelcorner.com/ external source, use with sendOnly = true",
|
"TNC": "https://thatnovelcorner.com/ external source, use with sendOnly = true",
|
||||||
"BBB": "https://bluebellsinbloom.wordpress.com/",
|
"BBB": "https://bluebellsinbloom.wordpress.com/",
|
||||||
|
"JN": "https://jnovels.com/ external"
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"novelURL": "",
|
"novelURL": "",
|
||||||
@@ -285,9 +286,17 @@ async function getNovelInfo(response, hosting) {
|
|||||||
info = [title, author, completed, 'https://novelfull.com' + firstChapterURL, 'https://novelfull.com' + coverURL];
|
info = [title, author, completed, 'https://novelfull.com' + firstChapterURL, 'https://novelfull.com' + coverURL];
|
||||||
break;
|
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':
|
case 'TNC':
|
||||||
html.querySelectorAll('a').forEach(elem => {
|
html.querySelectorAll('a').forEach(elem => {
|
||||||
if (elem.innerText.match('Volume')) {
|
if (elem.innerText.match('V|volume')) {
|
||||||
info = elem.innerText.match(/\d+/)[0];
|
info = elem.innerText.match(/\d+/)[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -325,7 +334,7 @@ function getChapterContent(response, hosting) {
|
|||||||
|
|
||||||
switch (hosting) {
|
switch (hosting) {
|
||||||
case 'NF':
|
case 'NF':
|
||||||
chapterContent += '<h1 class="chapter">' + html.querySelector('span.chapter-text').innerText + '</h3>';
|
chapterContent += '<h1 class="chapter">' + html.querySelector('span.chapter-text').innerText + '</h1>';
|
||||||
|
|
||||||
html.querySelectorAll('div#chapter-content p').forEach(element => {
|
html.querySelectorAll('div#chapter-content p').forEach(element => {
|
||||||
chapterContent += element.outerHTML;
|
chapterContent += element.outerHTML;
|
||||||
@@ -345,7 +354,7 @@ async function clearLog() {
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await loadConfig();
|
await loadConfig();
|
||||||
await clearLog()
|
await clearLog();
|
||||||
|
|
||||||
for (let i = 0; i < config['novels'].length; ++i) {
|
for (let i = 0; i < config['novels'].length; ++i) {
|
||||||
let novel = clone(config['novels'][i]);
|
let novel = clone(config['novels'][i]);
|
||||||
@@ -370,7 +379,7 @@ async function main() {
|
|||||||
const novelPath = `${config.downloadLocation}/${novel.title}`;
|
const novelPath = `${config.downloadLocation}/${novel.title}`;
|
||||||
const novelVolumeRegex = new RegExp(novel.sendOnlyRegex + '.' + novel.sendOnlyFormat);
|
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) {
|
if (lastVolumeOnline > novel.lastVolume) {
|
||||||
log(`New volume found online: ${novel.title} ${lastVolumeOnline} ${novel.novelURL}`);
|
log(`New volume found online: ${novel.title} ${lastVolumeOnline} ${novel.novelURL}`);
|
||||||
@@ -419,7 +428,7 @@ async function main() {
|
|||||||
async function downloadChaptersFunction(novel, i) {
|
async function downloadChaptersFunction(novel, i) {
|
||||||
let chapters = [];
|
let chapters = [];
|
||||||
let nextChapterURL;
|
let nextChapterURL;
|
||||||
let novelInfo = await fetchNovelInfo(novel['novelURL'], 'NF');
|
let novelInfo = await fetchNovelInfo(novel['novelURL'], novel.hosting);
|
||||||
|
|
||||||
novel['title'] = novelInfo[0];
|
novel['title'] = novelInfo[0];
|
||||||
novel['author'] = novelInfo[1];
|
novel['author'] = novelInfo[1];
|
||||||
@@ -432,19 +441,19 @@ async function main() {
|
|||||||
if (!novel['lastChapterURL']) {
|
if (!novel['lastChapterURL']) {
|
||||||
novel['lastChapterURL'] = novelInfo[3];
|
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]);
|
log('Downloaded chapter: ' + chapters.length + ' ' + novelInfo[3]);
|
||||||
chapters.push(chapter);
|
chapters.push(chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
let novelDir = `${config['downloadLocation']}/${novel['title']}`;
|
let novelDir = `${config['downloadLocation']}/${novel['title']}`;
|
||||||
|
|
||||||
const nextChapterURLtemp = await fetchChapter(novel['lastChapterURL'], 'NF');
|
const nextChapterURLtemp = await fetchChapter(novel['lastChapterURL'], novel.hosting);
|
||||||
nextChapterURL = nextChapterURLtemp[1];
|
nextChapterURL = nextChapterURLtemp[1];
|
||||||
|
|
||||||
while (nextChapterURL) {
|
while (nextChapterURL) {
|
||||||
novel['lastChapterURL'] = nextChapterURL;
|
novel['lastChapterURL'] = nextChapterURL;
|
||||||
let chapter = await fetchChapter(nextChapterURL, 'NF');
|
let chapter = await fetchChapter(nextChapterURL, novel.hosting);
|
||||||
log('Downloaded chapter: ' + chapters.length + ' ' + nextChapterURL);
|
log('Downloaded chapter: ' + chapters.length + ' ' + nextChapterURL);
|
||||||
chapters.push(chapter);
|
chapters.push(chapter);
|
||||||
nextChapterURL = chapter[1];
|
nextChapterURL = chapter[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user