feat: Plugins (#465)
* update * gitignore * base file * template * json generator * remove valid method * Update README.md README * update template * Update README.md * update template * not support async arrow function * remove valid method * basic plugin validation. * Update README.md * update template * Update README.md * add fetchFile lib. empy .language file * comment fetch * update * comment fetch * auto comment, update template, template.min * Update README.md * add option to test * reset version * Update README.md * small fix for LightNovelReader * comment fetch * minor: LL date format * refactor: rename project, remove html2text lib * fix: error if there's no plugin changed * implement cookies bypass * update template.min.js * add syosetu * fix: get last file in case removing. shorter id * shoter native language name * change app project name * testing with UI would be less painful :) * remove console.log * Update README.md for UI testing * fix Syosetu * remove try catch * add ranobehub * add json for ranobehub * wrong icon path :D * fix ranobehub * fix status ranobe * add french * fix css * add chireads * add indonesian * add sakura novel * add sakuranovel json * add spanish * add skynovels * fix skynovels * add agitoon * add turkish * add epiknovel * add portuguese * update template * cheerio_space * add novel Fullme * minor * lol, this source havent been finished before. cant help * cant bypass this * add hasutl * novelasligera not working properly * add novelpub, but no searching * add jaomix * fix jaomix * add ranoberf * add indowebnovel * add novelringan * add noveldeglace * search not work for this * add oasisTL, this should have better popularNovels * add tunovelaligera * this source need to fix search * add bestlightnovel * add comrade mao * minor fix * add divinedaolibrary * add freewebnovel * lol xD * minor * update json * fix icon novelawuxia * update site in for pluginItem * some changes for more convenient * remove try catch * Update README.md * remove * Update README.md * trying to use pre-commit * update README * feat: .env for repo config * add foxaholic (#2) * rebase fox * fox officially 1.0.0 --------- Co-authored-by: K1ngfish3r <trulyihu@gmail.com>
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
const cheerio = require('cheerio');
|
||||
const languages = require('@libs/languages');
|
||||
const isUrlAbsolute = require('@libs/isAbsoluteUrl');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
|
||||
const pluginId = 'LNR.org';
|
||||
const baseUrl = 'https://lightnovelreader.org';
|
||||
|
||||
async function popularNovels(page) {
|
||||
const url = baseUrl + '/ranking/top-rated/' + page;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
loadedCheerio('.category-items.ranking-category.cm-list > ul > li').each(
|
||||
function () {
|
||||
let novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
if (novelUrl && !isUrlAbsolute(novelUrl)) {
|
||||
novelUrl = baseUrl + novelUrl;
|
||||
}
|
||||
|
||||
if (novelUrl) {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.category-name a')
|
||||
.text()
|
||||
.trim();
|
||||
let novelCover = loadedCheerio(this)
|
||||
.find('.category-img img')
|
||||
.attr('src');
|
||||
|
||||
if (novelCover && !isUrlAbsolute(novelCover)) {
|
||||
novelCover = baseUrl + novelCover;
|
||||
}
|
||||
|
||||
const novel = {
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novel = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.section-header-title > h2').text();
|
||||
|
||||
let novelCover = loadedCheerio('.novels-detail img').attr('src');
|
||||
|
||||
novel.cover = novelCover
|
||||
? isUrlAbsolute(novelCover)
|
||||
? novelCover
|
||||
: baseUrl + novelCover
|
||||
: undefined;
|
||||
|
||||
novel.summary = loadedCheerio(
|
||||
'div.container > div > div.col-12.col-xl-9 > div > div:nth-child(5) > div',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = loadedCheerio(
|
||||
'div.novels-detail-right > ul > li:nth-child(6) > .novels-detail-right-in-right > a',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genres = loadedCheerio(
|
||||
'body > section:nth-child(4) > div > div > div.col-12.col-xl-9 > div > div:nth-child(2) > div > div.novels-detail-right > ul > li:nth-child(3) > div.novels-detail-right-in-right',
|
||||
)
|
||||
.text()
|
||||
.trim()
|
||||
|
||||
novel.status = loadedCheerio(
|
||||
'div.novels-detail-right > ul > li:nth-child(2) > .novels-detail-right-in-right',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
loadedCheerio('.cm-tabs-content > ul > li').each(function () {
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
if (chapterUrl && !isUrlAbsolute(chapterUrl)) {
|
||||
chapterUrl = baseUrl + chapterUrl;
|
||||
}
|
||||
|
||||
if (chapterUrl) {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
novel.chapters.push(chapter);
|
||||
}
|
||||
});
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter(chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterText = loadedCheerio('#chapterText').html() || '';
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = baseUrl + `/search/autocomplete?dataType=json&query=${searchTerm}`;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.json();
|
||||
const data = body.results || [];
|
||||
|
||||
const novels = [];
|
||||
|
||||
data.forEach(item => {
|
||||
let novelUrl = item.link;
|
||||
let novelName = item.original_title
|
||||
let novelCover = item.image;
|
||||
|
||||
novels.push({
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function fetchImage (url) {
|
||||
return await fetchFile(url, {});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: 'LightNovelReader',
|
||||
icon: 'src/en/lightnovelreader/icon.png',
|
||||
version: '1.0.0',
|
||||
site: baseUrl,
|
||||
lang: languages.English,
|
||||
description: 'This is description for plugin',
|
||||
protected: false,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const languages = require('@libs/languages');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
|
||||
const pluginId = 'NF.me';
|
||||
const sourceName = 'NovelFull.me';
|
||||
|
||||
const baseUrl = 'https://novelfull.me/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}popular?page=${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.book-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.title').text();
|
||||
const novelCover =
|
||||
'https:' + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find('.title a').attr('href').substring(1);
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
url,
|
||||
name: '',
|
||||
cover: '',
|
||||
author: '',
|
||||
status: '',
|
||||
genres: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.name h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
'https:' + loadedCheerio('.img-cover img').attr('data-src');
|
||||
|
||||
novel.summary = loadedCheerio(
|
||||
'body > div.layout > div.main-container.book-details > div > div.row.no-gutters > div.col-lg-8 > div.mt-1 > div.section.box.mt-1.summary > div.section-body > p.content',
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = 'Unknown';
|
||||
|
||||
novel.status = loadedCheerio(
|
||||
'body > div.layout > div.main-container.book-details > div > div.row.no-gutters > div.col-lg-8 > div.book-info > div.detail > div.meta.box.mt-1.p-10 > p:nth-child(1) > a > span',
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
novel.genres = loadedCheerio(
|
||||
'body > div.layout > div.main-container.book-details > div > div.row.no-gutters > div.col-lg-8 > div.book-info > div.detail > div.meta.box.mt-1.p-10 > p:nth-child(2)',
|
||||
)
|
||||
.text()
|
||||
?.replace('Genres :', '')
|
||||
.replace(/[\s\n]+/g, ' ')
|
||||
.trim();
|
||||
|
||||
let chapters = [];
|
||||
|
||||
const chaptersUrl =
|
||||
novelUrl.replace(baseUrl, 'https://novelfull.me/api/novels/') +
|
||||
'/chapters?source=detail';
|
||||
|
||||
const chaptersRequest = await fetchApi(chaptersUrl);
|
||||
const chaptersHtml = await chaptersRequest.text();
|
||||
|
||||
loadedCheerio = cheerio.load(chaptersHtml);
|
||||
|
||||
loadedCheerio('li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('.chapter-title')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('.chapter-update')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
loadedCheerio('#listen-chapter').remove();
|
||||
loadedCheerio('#google_translate_element').remove();
|
||||
|
||||
const chapterText = loadedCheerio('.chapter__content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}search?status=all&sort=views&q=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.book-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.title').text();
|
||||
const novelCover =
|
||||
'https:' + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find('.title a').attr('href').substring(1);
|
||||
|
||||
const novel = {name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
lang: languages.English,
|
||||
version: '1.0.0',
|
||||
icon: 'src/en/novelfullme/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = 'NO.net';
|
||||
const sourceName = 'novelsOnline';
|
||||
|
||||
const baseUrl = 'https://novelsonline.net';
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const result = await fetchApi(
|
||||
'https://novelsonline.net/sResults.php',
|
||||
{
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Accept-Language': 'pl,en-US;q=0.7,en;q=0.3',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
method: 'POST',
|
||||
body: 'q=' + encodeURIComponent(searchTerm),
|
||||
},
|
||||
pluginId
|
||||
).then(res => res.text());
|
||||
let $ = cheerio.load(result);
|
||||
|
||||
const headers = $('li');
|
||||
return headers
|
||||
.map((i, h) => {
|
||||
const novelName = $(h).text();
|
||||
const novelUrl = $(h).find('a').attr('href');
|
||||
const novelCover = $(h).find('img').attr('src');
|
||||
|
||||
if (!novelUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
})
|
||||
.get()
|
||||
.filter(sr => sr !== null);
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl){
|
||||
let novel = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
const result = await fetchApi(novelUrl).then(res => res.text());
|
||||
let $ = cheerio.load(result);
|
||||
|
||||
novel.name = $('h1').text();
|
||||
novel.cover = $('.novel-cover').find('a > img').attr('src');
|
||||
novel.author = $(
|
||||
'div.novel-details > div:nth-child(5) > div.novel-detail-body',
|
||||
)
|
||||
.find('li')
|
||||
.map((_, el) => $(el).text())
|
||||
.get()
|
||||
.join(', ');
|
||||
|
||||
novel.genres = $(
|
||||
'div.novel-details > div:nth-child(2) > div.novel-detail-body',
|
||||
)
|
||||
.find('li')
|
||||
.map((_, el) => $(el).text())
|
||||
.get()
|
||||
.join(',');
|
||||
|
||||
novel.summary = $(
|
||||
'div.novel-right > div > div:nth-child(1) > div.novel-detail-body',
|
||||
).text();
|
||||
|
||||
novel.chapters = $('ul.chapter-chs > li > a')
|
||||
.map((_, el) => {
|
||||
const chapterUrl = $(el).attr('href');
|
||||
const chapterName = $(el).text();
|
||||
|
||||
return {
|
||||
name: chapterName,
|
||||
releaseTime: '',
|
||||
url: chapterUrl,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function popularNovels (page) {
|
||||
return { novels: [] }; /** TO DO */
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl).then(res => res.text());
|
||||
let loadedCheerio = cheerio.load(result);
|
||||
|
||||
const chapterText = loadedCheerio('#contentall').html() || '';
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
lang: languages.English,
|
||||
icon: 'src/coverNotAvailable.jpg',
|
||||
version: '1.0.0',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = 'ANF.com';
|
||||
const sourceName = 'AllNovelFull';
|
||||
const baseUrl = 'https://allnovelfull.com';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}/most-popular?page=${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
console.log(result.ok);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
loadedCheerio('.col-truyen-main .list-truyen .row').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3.truyen-title > a').text();
|
||||
const novelCover =
|
||||
baseUrl + loadedCheerio(this).find('img.cover').attr('src');
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find('h3.truyen-title > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
};
|
||||
console.log(novel);
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('div.book > img').attr('alt');
|
||||
|
||||
novel.cover = baseUrl + loadedCheerio('div.book > img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('div.desc-text').text().trim();
|
||||
|
||||
novel.author = loadedCheerio('div.info > div > h3')
|
||||
.filter(function () {
|
||||
return loadedCheerio(this).text().trim() === 'Author:';
|
||||
})
|
||||
.siblings()
|
||||
.text();
|
||||
|
||||
novel.genres = loadedCheerio('div.info > div')
|
||||
.filter(function () {
|
||||
return loadedCheerio(this).find('h3').text().trim() === 'Genre:';
|
||||
})
|
||||
.text()
|
||||
.replace('Genre:', '');
|
||||
|
||||
novel.status = loadedCheerio('div.info > div > h3')
|
||||
.filter(function () {
|
||||
return loadedCheerio(this).text().trim() === 'Status:';
|
||||
})
|
||||
.next()
|
||||
.text();
|
||||
|
||||
const novelId = loadedCheerio('#rating').attr('data-novel-id');
|
||||
|
||||
async function getChapters (id) {
|
||||
const chapterListUrl = baseUrl + '/ajax/chapter-option?novelId=' + id;
|
||||
|
||||
const data = await fetchApi(chapterListUrl);
|
||||
const chapters = await data.text();
|
||||
|
||||
loadedCheerio = cheerio.load(chapters);
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('select > option').each(function () {
|
||||
let chapterName = loadedCheerio(this).text();
|
||||
let releaseDate = null;
|
||||
let chapterUrl = loadedCheerio(this)
|
||||
.attr('value')
|
||||
?.replace(`/${novelUrl}`, '');
|
||||
|
||||
if (chapterUrl) {
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return novelChapters;
|
||||
};
|
||||
|
||||
if (novelId) {
|
||||
novel.chapters = await getChapters(novelId);
|
||||
}
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = baseUrl + chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterText = loadedCheerio('#chapter-content').html() || '';
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm){
|
||||
const url = `${baseUrl}/search?keyword=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('div.col-truyen-main > div.list-truyen > .row').each(
|
||||
function () {
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find('h3.truyen-title > a').attr('href');
|
||||
|
||||
const novelName = loadedCheerio(this).find('h3.truyen-title > a').text();
|
||||
const novelCover = baseUrl + loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
if (novelUrl) {
|
||||
novels.push({
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/allnovelfull/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,143 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
const Status = require('@libs/novelStatus');
|
||||
|
||||
const pluginId = "BLN.com";
|
||||
const sourceName = 'BestLightNovel';
|
||||
|
||||
const baseUrl = 'https://bestlightnovel.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url =
|
||||
baseUrl + 'novel_list?type=topview&category=all&state=all&page=1' + page;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
url,
|
||||
name: '',
|
||||
cover: '',
|
||||
author: '',
|
||||
status: Status.Unknown,
|
||||
genres: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.truyen_info_right h1').text().trim();
|
||||
novel.cover = loadedCheerio('.info_image img').attr('src');
|
||||
novel.summary = loadedCheerio('#noidungm').text()?.trim();
|
||||
novel.author = loadedCheerio(
|
||||
'#main_body > div.cotgiua > div.truyen_info_wrapper > div.truyen_info > div.entry-header > div.truyen_if_wrap > ul > li:nth-child(2) > a',
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
let status = loadedCheerio(
|
||||
'#main_body > div.cotgiua > div.truyen_info_wrapper > div.truyen_info > div.entry-header > div.truyen_if_wrap > ul > li:nth-child(4) > a',
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
novel.status =
|
||||
status === 'ONGOING'
|
||||
? Status.Ongoing
|
||||
: status === 'COMPLETED'
|
||||
? Status.Completed
|
||||
: Status.Unknown;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('.chapter-list div.row').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('span:nth-child(2)')
|
||||
.text()
|
||||
.trim();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter ( chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterText = loadedCheerio('#vung_doc').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}search_novels/${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.update_item.list_category').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h3 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('h3 > a').attr('href');
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/bestlightnovel/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,149 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
const dayjs = require('dayjs');
|
||||
|
||||
const pluginId = 'comrademao';
|
||||
|
||||
const sourceName = 'Comrade Mao';
|
||||
|
||||
const baseUrl = 'https://comrademao.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
let url = baseUrl + 'page/' + page + '/?post_type=novel';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.listupd')
|
||||
.find('div.bs')
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tt').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = { url };
|
||||
|
||||
novel.name = loadedCheerio('.entry-title').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('div.thumbook > div > img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('div.infox > div:nth-child(6) > span > p')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genres = loadedCheerio('div.infox > div:nth-child(4) > span')
|
||||
.text()
|
||||
.replace(/\s/g, '');
|
||||
|
||||
novel.status = loadedCheerio('div.infox > div:nth-child(3) > span')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = loadedCheerio('div.infox > div:nth-child(2) > span')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('#chapterlist')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const releaseDate = dayjs(
|
||||
loadedCheerio(this).find('.chapterdate').text(),
|
||||
).format('LL');
|
||||
const chapterName = loadedCheerio(this).find('.chapternum').text();
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
releaseTime: releaseDate,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterText = loadedCheerio('#chaptercontent').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = baseUrl + '?s=' + searchTerm + '&post_type=novel';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.listupd')
|
||||
.find('div.bs')
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tt').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/comrademao/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,155 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const defaultCoverUri =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/icons/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
const pluginId = 'DDL.com';
|
||||
|
||||
const sourceName = 'Divine Dao Library';
|
||||
|
||||
const baseUrl = 'https://www.divinedaolibrary.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
let url = baseUrl + 'novels';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('#main')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = defaultCoverUri;
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {url };
|
||||
|
||||
novel.name = loadedCheerio('h1.entry-title').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.entry-content').find('img').attr('data-ezsrc') || defaultCoverUri;
|
||||
|
||||
novel.summary = loadedCheerio('#main > article > div > p:nth-child(6)')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.genres = null;
|
||||
|
||||
novel.status = null;
|
||||
|
||||
novel.author = loadedCheerio('#main > article > div > h3:nth-child(2)')
|
||||
.text()
|
||||
.replace(/Author:/g, '')
|
||||
.trim();
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('#main')
|
||||
.find('li > span > a')
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).attr('href');
|
||||
|
||||
novelChapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterName = loadedCheerio('.entry-title').text().trim();
|
||||
|
||||
let chapterText = loadedCheerio('.entry-content').html();
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = loadedCheerio('.page-header').html();
|
||||
}
|
||||
|
||||
chapterText = `<p><h1>${chapterName}</h1></p>` + chapterText;
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
let url = baseUrl + 'novels';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('#main')
|
||||
.find('li')
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = defaultCoverUri;
|
||||
const novelUrl = loadedCheerio(this).find(' a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
novels = novels.filter(novel =>
|
||||
novel.name.toLowerCase().includes(searchTerm.toLowerCase()),
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/divinedaolibrary/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,162 @@
|
||||
const cheerio = require('cheerio');
|
||||
const languages = require('@libs/languages');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
|
||||
const pluginId = 'foxaholic';
|
||||
const baseUrl = 'https://www.foxaholic.com/';
|
||||
|
||||
async function popularNovels (page){
|
||||
const link = `${baseUrl}novel/page/${page}/?m_orderby=rating`;
|
||||
|
||||
const result = await fetchApi(link, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const name = loadedCheerio(this).find('.h5 > a').text();
|
||||
const cover = loadedCheerio(this).find('img').attr('data-src');
|
||||
const url = loadedCheerio(this).find('.h5 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name,
|
||||
url,
|
||||
cover,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl){
|
||||
const url = novelUrl;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novel = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.post-title > h1')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
novel.cover = loadedCheerio('.summary_image > a > img').attr('data-src');
|
||||
|
||||
loadedCheerio('.post-content_item').each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find('.summary-heading > h5')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find('.summary-content')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre':
|
||||
novel.genre = detail.trim().replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author':
|
||||
novel.author = detail.trim();
|
||||
break;
|
||||
case 'Novel':
|
||||
novel.status = detail.trim();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('.description-summary > div.summary__content')
|
||||
.find('em')
|
||||
.remove();
|
||||
|
||||
novel.summary = loadedCheerio('.description-summary > div.summary__content')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let chapter = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const name = loadedCheerio(this)
|
||||
.find('a')
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '')
|
||||
.trim();
|
||||
const releaseTime = loadedCheerio(this).find('span').text().trim();
|
||||
const url = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
chapter.push({ name, releaseTime, url });
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl){
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterText = loadedCheerio('.reading-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}&post_type=wp-manga`;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.h4 > a').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl = loadedCheerio(this).find('.h4 > a').attr('href');
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function fetchImage (url){
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
}
|
||||
return await fetchFile(url, {headers: headers});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: 'Foxaholic',
|
||||
version: '1.0.0',
|
||||
icon: 'src/en/foxaholic/icon.png',
|
||||
site: baseUrl,
|
||||
lang: languages.English,
|
||||
description: 'Digging Pits',
|
||||
protected: false,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
};
|
||||
@@ -0,0 +1,173 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = 'FWN.com';
|
||||
const sourceName = "Web NOVEL";
|
||||
const baseUrl = 'https://freewebnovel.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
let url = baseUrl + 'completed-novel/' + page;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.li-row').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tit').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
|
||||
let novelUrl = 'https://freewebnovel.com' + loadedCheerio(this)
|
||||
.find('h3 > a')
|
||||
.attr('href')
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {};
|
||||
|
||||
novel.url = url;
|
||||
|
||||
novel.name = loadedCheerio('h1.tit').text();
|
||||
|
||||
novel.cover = loadedCheerio('.pic > img').attr('src');
|
||||
|
||||
novel.genres = loadedCheerio('[title=Genre]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.author = loadedCheerio('[title=Author]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
novel.artist = null;
|
||||
|
||||
novel.status = loadedCheerio('[title=Status]')
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '');
|
||||
|
||||
let novelSummary = loadedCheerio('.inner').text().trim();
|
||||
novel.summary = novelSummary;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
let latestChapter;
|
||||
|
||||
loadedCheerio('h3.tit').each(function (res) {
|
||||
if (loadedCheerio(this).find('a').text() === novel.name) {
|
||||
latestChapter = loadedCheerio(this)
|
||||
.next()
|
||||
.find('span.s3')
|
||||
.text()
|
||||
.match(/\d+/);
|
||||
}
|
||||
});
|
||||
|
||||
latestChapter = latestChapter[0];
|
||||
let prefixUrl = novelUrl.replace('.html', '/');
|
||||
|
||||
for (let i = 1; i <= parseInt(latestChapter, 10); i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
let chapterUrl = 'chapter-' + i;
|
||||
chapterUrl = `${prefixUrl}${chapterUrl}.html`
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate, url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterText = loadedCheerio('div.txt').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = baseUrl + 'search/';
|
||||
|
||||
const formData = {
|
||||
searchkey: searchTerm,
|
||||
};
|
||||
|
||||
const result = await fetchApi(url, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.li-row > .li > .con').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.tit').text();
|
||||
const novelCover = loadedCheerio(this)
|
||||
.find('.pic > a > img')
|
||||
.attr('data-cfsrc');
|
||||
|
||||
let novelUrl = "https://freewebnovel.com" + loadedCheerio(this)
|
||||
.find('h3 > a')
|
||||
.attr('href')
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/freewebnovel/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const baseUrl = 'https://www.novelpub.com/';
|
||||
|
||||
const sourceName = 'NovelPub';
|
||||
const pluginId = 'novelpub.com';
|
||||
|
||||
const headers = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
|
||||
};
|
||||
|
||||
async function popularNovels (page) {
|
||||
let url = baseUrl + 'browse/all/popular/all/' + page;
|
||||
|
||||
const result = await fetchApi(url, { method: 'GET', headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.novel-item.ads').remove();
|
||||
|
||||
loadedCheerio('.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.novel-title').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelUrl =
|
||||
baseUrl +
|
||||
loadedCheerio(this).find('.novel-title > a').attr('href').substring(1);
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, { method: 'GET', headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = { url, genres: '' };
|
||||
|
||||
novel.name = loadedCheerio('h1.novel-title').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('figure.cover > img').attr('data-src');
|
||||
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genres +=
|
||||
loadedCheerio(this)
|
||||
.text()
|
||||
.replace(/[\t\n]/g, '') + ',';
|
||||
});
|
||||
|
||||
loadedCheerio('div.header-stats > span').each(function () {
|
||||
if (loadedCheerio(this).find('small').text() === 'Status') {
|
||||
novel.status = loadedCheerio(this).find('strong').text();
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = novel.genres.slice(0, -1);
|
||||
|
||||
novel.author = loadedCheerio('.author > a > span').text();
|
||||
|
||||
novel.summary = loadedCheerio('.summary > .content').text().trim();
|
||||
|
||||
const delay = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
let lastPage = 1;
|
||||
|
||||
lastPage = loadedCheerio(
|
||||
'#novel > header > div.header-body.container > div.novel-info > div.header-stats > span:nth-child(1) > strong',
|
||||
)
|
||||
.text()
|
||||
?.trim();
|
||||
|
||||
lastPage = Math.ceil(lastPage / 100);
|
||||
|
||||
const getChapters = async () => {
|
||||
let novelChapters = [];
|
||||
|
||||
for (let i = 1; i <= lastPage; i++) {
|
||||
const chaptersUrl = `${novelUrl}/chapters/page-${i}`;
|
||||
|
||||
const chaptersRequest = await fetchApi(chaptersUrl, { headers });
|
||||
const chaptersHtml = await chaptersRequest.text();
|
||||
|
||||
loadedCheerio = cheerio.load(chaptersHtml);
|
||||
|
||||
loadedCheerio('.chapter-list li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('.chapter-title')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('.chapter-update')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl =
|
||||
baseUrl + loadedCheerio(this).find('a').attr('href').substring(1);
|
||||
|
||||
novelChapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
await delay(1000);
|
||||
}
|
||||
|
||||
return novelChapters;
|
||||
};
|
||||
|
||||
novel.chapters = await getChapters();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url, { method: 'GET', headers });
|
||||
|
||||
const body = await result.text();
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterText = loadedCheerio('#chapter-container').html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
// They have API to search, pls update it, im quite lazy xD
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}lnwsearchlive?inputContent=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url, { method: 'GET', headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
// let results = JSON.parse(loadedCheerio('body').text());
|
||||
|
||||
// loadedCheerio = cheerio.load(results.resultview);
|
||||
|
||||
// loadedCheerio('.novel-item').each(function () {
|
||||
// const novelName = loadedCheerio(this).find('.novel-title').text().trim();
|
||||
// const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
// const novelUrl =
|
||||
// baseUrl + loadedCheerio(this).find('a').attr('href').substring(1);
|
||||
|
||||
// const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
// novels.push(novel);
|
||||
// });
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
lang: languages.English,
|
||||
icon: 'src/en/novelpub/icon.png',
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
Reference in New Issue
Block a user