Full TS for Plugins (#538)
* remove lang, descrription in plugin script * remove languages import * Update README.md * fix: missing lang * clean: remove description * feat(Add Sources) (#15) * add many sources * add showToast * feat(Add Source): (#16) * add source * remove descriptions * Early Novel & Fast Novel (#1) * some more plugin * plugin * try something new * yes * try yes * genres is plural * fastnovel full fix * testings * early check * earlynovel fixed * showToast check * earlynovel done * fastnovel fixe * again * showToasts again * fix for fastnovel * done * for pr * Update freenovelupdates.js * MTL Reader and MTL Novel (#2) * first * test * wops * mtlreaders * ok * for PR * Nitro Scans and Novel Hold (#3) * start feature * more feature * something * eslint * yes * maybe * wa * asdasd * amazing * change it up * for pr * WPmangastream and Novelfull (#4) (#17) * source generation * fix json parse error * update plguins * delete fetchApi, nobleMTL (.js) * delete showToast.js * Typescript Support (#18) * Initial TS Config * Initial TS Config * Fix most errors * Fix test webserver * Fix webserver isPlugin not working * Fix typos * Add check if plugins have all the fields * Move exports.protected to the bottom of the plugin * Change username, reponame and branchname * Fix no exports error * Fix type * Fix typo in tsc_fix * Remove const from exports to not re-define consts * Readd const becuause exports may not exist. * Fix plugins to work in-app * Fix NobleMTL * Remove fix_ts.ts * Change template.ts * delete cheerio_space * move api into ./testweb * remove js dir * remove js dir (again) * remove ./js (again) * init multisrc generator (test) * remove module.exports in libs * madara generator * update template * rename generator, TS for hako * fix icon url for madara * fix icon for madara (again) * update Readme, nodemon * export default for all libs * fix madara novelurl * update: pluginId, name, filename for madara * feat: check same id error * update: precommit, fix: require.default * Revert "update: precommit, fix: require.default" This reverts commit c642c5c72241f13eccfe417210c22272c4739ffa. * Port all plugins to ts (#19) - fix cheerio - remove export default - fix spelling * update template * add multisrc noveltl, update generator param, fix web search * fix undefined id for Snailulitka * add rulate multisrc, fix max length textarea * add readwn multisrc * delete: erolate and rulate are in multisrc * Change broken extension and show error on commit for those files (#20) * Change to .broken.ts and show error on commit for those files * remove novelStatus * fix: wrong id in github action * remove mangastream multisrc * update icon for readwn multisrc --------- Co-authored-by: K1ngfish3r <trulyihu@gmail.com> Co-authored-by: Marcin Majewski <skilletssgames@gmail.com>
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "ar-mtl";
|
||||
export const name = "ArMTL [madara]";
|
||||
export const icon = "multisrc/madara/icons/armtl.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://ar-mtl.club/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "arnovel";
|
||||
export const name = "ArNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/arnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://arnovel.me/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "hizomanga";
|
||||
export const name = "HizoManga [madara]";
|
||||
export const icon = "multisrc/madara/icons/hizomanga.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://hizomanga.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "serie" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "serie" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novel4up";
|
||||
export const name = "Novel4Up [madara]";
|
||||
export const icon = "multisrc/madara/icons/novel4up.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://novel4up.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "riwyat";
|
||||
export const name = "Riwyat [madara]";
|
||||
export const icon = "multisrc/madara/icons/riwyat.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://riwyat.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "teamxnovel";
|
||||
export const name = "TeamXNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/teamxnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://teamxnovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,323 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { FilterInputs } from "@libs/filterInputs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "kolnovel";
|
||||
export const name = "KolNovel";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "multisrc/wpmangastream/icons/kolnovel.png";
|
||||
export const site = "https://kolnovel.com/";
|
||||
module.exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters }
|
||||
) {
|
||||
let link = `${baseUrl}series/?page=${page}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length)
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
link += "&status=" + (filters?.status ? filters.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters.order : "popular");
|
||||
|
||||
const body = await fetchApi(link, {}, pluginId).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function parseNovelAndChapters(novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1.entry-title").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
|
||||
loadedCheerio("div.serl:nth-child(3) > span").each(function () {
|
||||
const detailName = loadedCheerio(this).text().trim();
|
||||
const detail = loadedCheerio(this).next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "الكاتب":
|
||||
case "Author":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio("div.sertostat > span").attr("class");
|
||||
|
||||
novel.genres = loadedCheerio(".sertogenre")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
novel.summary = loadedCheerio(".sersys")
|
||||
.find("br")
|
||||
.replaceWith("\n")
|
||||
.end()
|
||||
.text();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".eplister")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const chapterName =
|
||||
loadedCheerio(this).find(".epl-num").text() +
|
||||
" - " +
|
||||
loadedCheerio(this).find(".epl-title").text();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find(".epl-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function parseChapter(
|
||||
chapterUrl
|
||||
) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let ignore = loadedCheerio(".epcontent > p").next().attr("class");
|
||||
loadedCheerio(`p.${ignore}`).remove();
|
||||
let chapterText = loadedCheerio(".epcontent").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
export const searchNovels: Plugin.searchNovels = async function searchNovels(
|
||||
searchTerm
|
||||
) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function fetchImage(url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
export const filters = [
|
||||
{
|
||||
key: "order",
|
||||
label: "ترتيب حسب",
|
||||
values: [
|
||||
{ label: "الإعداد الأولي", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
|
||||
{ label: "أخر التحديثات", value: "update" },
|
||||
|
||||
{ label: "أخر ما تم إضافته", value: "latest" },
|
||||
|
||||
{ label: "الرائجة", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
label: "الحالة",
|
||||
values: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
|
||||
{ label: "Hiatus", value: "hiatus" },
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
label: "النوع",
|
||||
values: [
|
||||
{ label: "إنجليزية", value: "english" },
|
||||
|
||||
{ label: "روايةلايت", value: "light-novel" },
|
||||
|
||||
{ label: "روايةويب", value: "web-novel" },
|
||||
|
||||
{ label: "صينية", value: "chinese" },
|
||||
|
||||
{ label: "عربية", value: "arabic" },
|
||||
|
||||
{ label: "كورية", value: "korean" },
|
||||
|
||||
{ label: "يابانية", value: "japanese" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
label: "تصنيف",
|
||||
values: [
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
|
||||
{ label: "Xianxia", value: "xianxia" },
|
||||
|
||||
{ label: "XUANHUAN", value: "xuanhuan" },
|
||||
|
||||
{ label: "أكشن", value: "action" },
|
||||
|
||||
{ label: "إثارة", value: "excitement" },
|
||||
|
||||
{ label: "إنتقالالىعالمأخر", value: "isekai" },
|
||||
|
||||
{ label: "إيتشي", value: "etchi" },
|
||||
|
||||
{ label: "الخيالالعلمي", value: "sci-fi" },
|
||||
|
||||
{ label: "بوليسي", value: "policy" },
|
||||
|
||||
{ label: "تاريخي", value: "historical" },
|
||||
|
||||
{ label: "تحقيقات", value: "%d8%aa%d8%ad%d9%82%d9%8a%d9%82" },
|
||||
|
||||
{ label: "تقمصشخصيات", value: "rpg" },
|
||||
|
||||
{ label: "جريمة", value: "crime" },
|
||||
|
||||
{ label: "جوسى", value: "josei" },
|
||||
|
||||
{ label: "حريم", value: "harem" },
|
||||
|
||||
{ label: "حياةمدرسية", value: "school-life" },
|
||||
|
||||
{ label: "خيالي(فانتازيا)", value: "fantasy" },
|
||||
|
||||
{ label: "دراما", value: "drama" },
|
||||
|
||||
{ label: "رعب", value: "horror" },
|
||||
|
||||
{ label: "رومانسي", value: "romantic" },
|
||||
|
||||
{ label: "سحر", value: "magic" },
|
||||
|
||||
{ label: "سينن", value: "senen" },
|
||||
|
||||
{ label: "شريحةمنالحياة", value: "slice-of-life" },
|
||||
|
||||
{ label: "شوجو", value: "shojo" },
|
||||
|
||||
{ label: "شونين", value: "shonen" },
|
||||
|
||||
{ label: "طبي", value: "medical" },
|
||||
|
||||
{ label: "ظواهرخارقةللطبيعة", value: "supernatural" },
|
||||
|
||||
{ label: "غموض", value: "mysteries" },
|
||||
|
||||
{ label: "فنونالقتال", value: "martial-arts" },
|
||||
|
||||
{ label: "قوىخارقة", value: "superpower" },
|
||||
|
||||
{ label: "كوميدي", value: "comedy" },
|
||||
|
||||
{ label: "مأساوي", value: "tragedy" },
|
||||
|
||||
{ label: "مابعدالكارثة", value: "after-the-disaster" },
|
||||
|
||||
{ label: "مغامرة", value: "adventure" },
|
||||
|
||||
{ label: "ميكا", value: "mechanical" },
|
||||
|
||||
{ label: "ناضج", value: "mature" },
|
||||
|
||||
{ label: "نفسي", value: "psychological" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "boxnovel";
|
||||
export const name = "BoxNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/boxnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://boxnovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "clicknovel";
|
||||
export const name = "ClickNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/clicknovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://clicknovel.net/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "cratenovel";
|
||||
export const name = "CrateNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/cratenovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://cratenovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "daonovel";
|
||||
export const name = "DaoNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/daonovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://daonovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novels-list" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novels" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "fanTLS";
|
||||
export const name = "Fans Translations [madara]";
|
||||
export const icon = "multisrc/madara/icons/fanstranslations.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://fanstranslations.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "1stkissnovel";
|
||||
export const name = "FirstKissNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/firstkissnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://1stkissnovel.org/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "freenovel.me";
|
||||
export const name = "FreeNovelMe [madara]";
|
||||
export const icon = "multisrc/madara/icons/freenovelme.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://freenovel.me/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "guavaread";
|
||||
export const name = "Guavaread [madara]";
|
||||
export const icon = "multisrc/madara/icons/guavaread.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://guavaread.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "lnheaven";
|
||||
export const name = "LightNovelHeaven [madara]";
|
||||
export const icon = "multisrc/madara/icons/lightnovelheaven.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://lightnovelheaven.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "series" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "series" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,168 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "LNR.org";
|
||||
export const name = "LightNovelReader";
|
||||
export const icon = "src/en/lightnovelreader/icon.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://lightnovelreader.org";
|
||||
exports.protected = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = baseUrl + "/ranking/top-rated/" + page;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
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: Chapter.Item = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
novel.chapters?.push(chapter);
|
||||
}
|
||||
});
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#chapterText").html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (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: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
return await fetchFile(url, {});
|
||||
};
|
||||
@@ -1,178 +0,0 @@
|
||||
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,198 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
// import dayjs from 'dayjs';
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
// import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
// import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
// import { showToast } from "@libs/showToast";
|
||||
// import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
// import { NovelStatus } from '@libs/novelStatus';
|
||||
// import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
|
||||
export const id = "Ltnovel.com";
|
||||
export const name = "Ltnovel.com";
|
||||
export const icon = "multisrc/readwn/icon/ltnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.ltnovel.com/";
|
||||
// export const filters: Filter[] = [];
|
||||
exports["protected"] = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters, showLatestNovels }
|
||||
) {
|
||||
const novels: Novel.Item[] = [];
|
||||
const pageNo = page - 1;
|
||||
|
||||
const url = baseUrl + 'list/all/all-onclick-' + pageNo +'.html';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = loadedCheerio(this)
|
||||
.find('.novel-cover > img')
|
||||
.attr('data-src');
|
||||
|
||||
const novelCover = baseUrl + coverUri;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('h1.novel-title').text();
|
||||
|
||||
const coverUri = loadedCheerio('figure.cover > img').attr('data-src');
|
||||
novel.cover = baseUrl + coverUri;
|
||||
|
||||
novel.summary = loadedCheerio('.summary')
|
||||
.text()
|
||||
.replace('Summary', '')
|
||||
.trim();
|
||||
|
||||
novel.genres = '';
|
||||
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genres += loadedCheerio(this).text().trim() + ',';
|
||||
});
|
||||
|
||||
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('span[itemprop=author]').text();
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
const novelId = novelUrl.replace('.html', '').replace(baseUrl, '');
|
||||
|
||||
const latestChapterNo = parseInt(loadedCheerio('.header-stats')
|
||||
.find('span > strong')
|
||||
.first()
|
||||
.text()
|
||||
.trim());
|
||||
|
||||
let lastChapterNo = 1;
|
||||
loadedCheerio('.chapter-list li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a .chapter-title')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = baseUrl + loadedCheerio(this).find('a').attr('href')?.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('a .chapter-update')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
lastChapterNo = parseInt(loadedCheerio(this).find('a .chapter-no').text().trim());
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate, url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
// Itterate once more before loop to finish off
|
||||
lastChapterNo++;
|
||||
for (let i = lastChapterNo; i <= latestChapterNo; i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
const chapterUrl = baseUrl + novelId+'_'+ i +'.html';
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate,url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.chapter-content').html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const searchUrl = baseUrl + 'e/search/index.php';
|
||||
|
||||
const result = await fetchApi(searchUrl, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Referer: baseUrl + 'search.html',
|
||||
Origin: baseUrl,
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
show: 'title',
|
||||
tempid: 1,
|
||||
tbname: 'news',
|
||||
keyboard: searchTerm,
|
||||
}),
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = baseUrl + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelCover = baseUrl + coverUri;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url, {});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "lunarletters";
|
||||
export const name = "LunarLetters [madara]";
|
||||
export const icon = "multisrc/madara/icons/lunarletters.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.lunarletters.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "series" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "series" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "mtlnovel.club";
|
||||
export const name = "MTLNovel.Club [madara]";
|
||||
export const icon = "multisrc/madara/icons/mtlnovel.club.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://mtlnovel.club/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "mtl-novel";
|
||||
export const name = "MTL-Novel [madara]";
|
||||
export const icon = "multisrc/madara/icons/mtl-novel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://mtl-novel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "mostnovel";
|
||||
export const name = "MostNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/mostnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://mostnovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "manga" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "mysticalmerries";
|
||||
export const name = "MysticalSeries [madara]";
|
||||
export const icon = "multisrc/madara/icons/mysticalseries.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://mysticalmerries.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "series" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "series" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "neosekaiTLS";
|
||||
export const name = "NeoSekai Translations [madara]";
|
||||
export const icon = "multisrc/madara/icons/neosekaitranslations.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.neosekaitranslations.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "nocturneTLS";
|
||||
export const name = "Nocturne Translations [madara]";
|
||||
export const icon = "multisrc/madara/icons/nocturnetranslations.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://nocturnetls.net/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novels" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novels" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "noobchanTL";
|
||||
export const name = "Noobchan Translation [madara]";
|
||||
export const icon = "multisrc/madara/icons/noobchantranslation.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://noobchan.xyz/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -1,167 +0,0 @@
|
||||
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,165 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "NF.me";
|
||||
export const name = "NovelFull.me";
|
||||
export const site = "https://novelfull.me/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/novelfullme/icon.png";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}popular?page=${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
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: Chapter.Item[] = [];
|
||||
|
||||
const chaptersUrl =
|
||||
novelUrl.replace(baseUrl, "https://novelfull.me/api/novels/") +
|
||||
"/chapters?source=detail";
|
||||
|
||||
const chaptersRequest = await fetchApi(chaptersUrl);
|
||||
const chaptersHtml = await chaptersRequest.text();
|
||||
|
||||
loadedCheerio = parseHTML(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");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("#listen-chapter").remove();
|
||||
loadedCheerio("#google_translate_element").remove();
|
||||
|
||||
const chapterText = loadedCheerio(".chapter__content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search?status=all&sort=views&q=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novelmultiverse";
|
||||
export const name = "NovelMultiverse [madara]";
|
||||
export const icon = "multisrc/madara/icons/novelmultiverse.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.novelmultiverse.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -1,120 +0,0 @@
|
||||
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,111 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "NO.net";
|
||||
export const name = "novelsOnline";
|
||||
export const site = "https://novelsonline.net";
|
||||
export const icon = "src/coverNotAvailable.jpg";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const pluginId = id;
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (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 $ = parseHTML(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);
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
let novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
const result = await fetchApi(novelUrl).then((res) => res.text());
|
||||
let $ = parseHTML(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,
|
||||
} as Chapter.Item;
|
||||
})
|
||||
.get();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
return []; /** TO DO */
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
let loadedCheerio = parseHTML(result);
|
||||
|
||||
const chapterText = loadedCheerio("#contentall").html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novelr18";
|
||||
export const name = "NovelR18 [madara]";
|
||||
export const icon = "multisrc/madara/icons/novelr18.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://novelr18.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novelTL";
|
||||
export const name = "NovelTranslate [madara]";
|
||||
export const icon = "multisrc/madara/icons/noveltranslate.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://noveltranslate.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "all-novels" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,198 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
// import dayjs from 'dayjs';
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
// import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
// import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
// import { showToast } from "@libs/showToast";
|
||||
// import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
// import { NovelStatus } from '@libs/novelStatus';
|
||||
// import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
|
||||
export const id = "Novelmt.com";
|
||||
export const name = "Novelmt.com";
|
||||
export const icon = "multisrc/readwn/icon/novelmt.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.novelmt.com/";
|
||||
// export const filters: Filter[] = [];
|
||||
exports["protected"] = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters, showLatestNovels }
|
||||
) {
|
||||
const novels: Novel.Item[] = [];
|
||||
const pageNo = page - 1;
|
||||
|
||||
const url = baseUrl + 'list/all/all-onclick-' + pageNo +'.html';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = loadedCheerio(this)
|
||||
.find('.novel-cover > img')
|
||||
.attr('data-src');
|
||||
|
||||
const novelCover = baseUrl + coverUri;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('h1.novel-title').text();
|
||||
|
||||
const coverUri = loadedCheerio('figure.cover > img').attr('data-src');
|
||||
novel.cover = baseUrl + coverUri;
|
||||
|
||||
novel.summary = loadedCheerio('.summary')
|
||||
.text()
|
||||
.replace('Summary', '')
|
||||
.trim();
|
||||
|
||||
novel.genres = '';
|
||||
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genres += loadedCheerio(this).text().trim() + ',';
|
||||
});
|
||||
|
||||
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('span[itemprop=author]').text();
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
const novelId = novelUrl.replace('.html', '').replace(baseUrl, '');
|
||||
|
||||
const latestChapterNo = parseInt(loadedCheerio('.header-stats')
|
||||
.find('span > strong')
|
||||
.first()
|
||||
.text()
|
||||
.trim());
|
||||
|
||||
let lastChapterNo = 1;
|
||||
loadedCheerio('.chapter-list li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a .chapter-title')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = baseUrl + loadedCheerio(this).find('a').attr('href')?.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('a .chapter-update')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
lastChapterNo = parseInt(loadedCheerio(this).find('a .chapter-no').text().trim());
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate, url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
// Itterate once more before loop to finish off
|
||||
lastChapterNo++;
|
||||
for (let i = lastChapterNo; i <= latestChapterNo; i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
const chapterUrl = baseUrl + novelId+'_'+ i +'.html';
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate,url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.chapter-content').html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const searchUrl = baseUrl + 'e/search/index.php';
|
||||
|
||||
const result = await fetchApi(searchUrl, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Referer: baseUrl + 'search.html',
|
||||
Origin: baseUrl,
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
show: 'title',
|
||||
tempid: 1,
|
||||
tbname: 'news',
|
||||
keyboard: searchTerm,
|
||||
}),
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = baseUrl + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelCover = baseUrl + coverUri;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url, {});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novelroom";
|
||||
export const name = "Novelroom.net [madara]";
|
||||
export const icon = "multisrc/madara/icons/novelroom.net.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://novelroom.net/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "manga" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "novelstic";
|
||||
export const name = "Novelstic [madara]";
|
||||
export const icon = "multisrc/madara/icons/novelstic.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://novelstic.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "onlymtl";
|
||||
export const name = "OnlyMTL [madara]";
|
||||
export const icon = "multisrc/madara/icons/onlymtl.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.onlymtl.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "readwebnovels";
|
||||
export const name = "ReadWebNovels [madara]";
|
||||
export const icon = "multisrc/madara/icons/readwebnovels.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://readwebnovels.net/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,198 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
// import dayjs from 'dayjs';
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
// import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
// import { isUrlAbsolute } from '@libs/isAbsoluteUrl';
|
||||
// import { showToast } from "@libs/showToast";
|
||||
// import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
// import { NovelStatus } from '@libs/novelStatus';
|
||||
// import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
|
||||
export const id = "Readwn.com";
|
||||
export const name = "Readwn.com";
|
||||
export const icon = "multisrc/readwn/icon/readwn.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.readwn.com/";
|
||||
// export const filters: Filter[] = [];
|
||||
exports["protected"] = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters, showLatestNovels }
|
||||
) {
|
||||
const novels: Novel.Item[] = [];
|
||||
const pageNo = page - 1;
|
||||
|
||||
const url = baseUrl + 'list/all/all-onclick-' + pageNo +'.html';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = loadedCheerio(this)
|
||||
.find('.novel-cover > img')
|
||||
.attr('data-src');
|
||||
|
||||
const novelCover = baseUrl + coverUri;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('h1.novel-title').text();
|
||||
|
||||
const coverUri = loadedCheerio('figure.cover > img').attr('data-src');
|
||||
novel.cover = baseUrl + coverUri;
|
||||
|
||||
novel.summary = loadedCheerio('.summary')
|
||||
.text()
|
||||
.replace('Summary', '')
|
||||
.trim();
|
||||
|
||||
novel.genres = '';
|
||||
|
||||
loadedCheerio('div.categories > ul > li').each(function () {
|
||||
novel.genres += loadedCheerio(this).text().trim() + ',';
|
||||
});
|
||||
|
||||
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('span[itemprop=author]').text();
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
const novelId = novelUrl.replace('.html', '').replace(baseUrl, '');
|
||||
|
||||
const latestChapterNo = parseInt(loadedCheerio('.header-stats')
|
||||
.find('span > strong')
|
||||
.first()
|
||||
.text()
|
||||
.trim());
|
||||
|
||||
let lastChapterNo = 1;
|
||||
loadedCheerio('.chapter-list li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a .chapter-title')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = baseUrl + loadedCheerio(this).find('a').attr('href')?.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('a .chapter-update')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
lastChapterNo = parseInt(loadedCheerio(this).find('a .chapter-no').text().trim());
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate, url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
// Itterate once more before loop to finish off
|
||||
lastChapterNo++;
|
||||
for (let i = lastChapterNo; i <= latestChapterNo; i++) {
|
||||
const chapterName = 'Chapter ' + i;
|
||||
const chapterUrl = baseUrl + novelId+'_'+ i +'.html';
|
||||
const releaseDate = null;
|
||||
|
||||
const chapter = { name: chapterName, releaseTime: releaseDate,url: chapterUrl };
|
||||
|
||||
novelChapters.push(chapter);
|
||||
}
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio('.chapter-content').html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const searchUrl = baseUrl + 'e/search/index.php';
|
||||
|
||||
const result = await fetchApi(searchUrl, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
Referer: baseUrl + 'search.html',
|
||||
Origin: baseUrl,
|
||||
'user-agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36',
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
show: 'title',
|
||||
tempid: 1,
|
||||
tbname: 'news',
|
||||
keyboard: searchTerm,
|
||||
}),
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('li.novel-item').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h4').text();
|
||||
const novelUrl = baseUrl + loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const coverUri = baseUrl + loadedCheerio(this).find('img').attr('data-src');
|
||||
const novelCover = baseUrl + coverUri;
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url, {});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "sleeptTLS";
|
||||
export const name = "SleepyTranslations [madara]";
|
||||
export const icon = "multisrc/madara/icons/sleepytranslations.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://sleepytranslations.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "series" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "series" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "sonicmtl";
|
||||
export const name = "SonicMTL [madara]";
|
||||
export const icon = "multisrc/madara/icons/sonicmtl.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.sonicmtl.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "sugarbbscan";
|
||||
export const name = "Sugar Babies [madara]";
|
||||
export const icon = "multisrc/madara/icons/sugarbabies.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://sugarbbscan.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "series" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "series" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "sweetEscapeTL";
|
||||
export const name = "Sweet Escape Translations [madara]";
|
||||
export const icon = "multisrc/madara/icons/sweetescapetranslations.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://sweetescapetranslations.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "manga" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "webnovelover";
|
||||
export const name = "WebNovelLover [madara]";
|
||||
export const icon = "multisrc/madara/icons/webnovellover.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://www.webnovelover.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "wuxiaworld.site";
|
||||
export const name = "WuxiaWorld.Site [madara]";
|
||||
export const icon = "multisrc/madara/icons/wuxiaworld.site.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://wuxiaworld.site/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "zetroTL";
|
||||
export const name = "Zetro Translation [madara]";
|
||||
export const icon = "multisrc/madara/icons/zetrotranslation.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://zetrotranslation.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "zinnovel";
|
||||
export const name = "ZinnNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/zinnnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://zinnovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "manga" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "manga" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -1,171 +0,0 @@
|
||||
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,200 @@
|
||||
import { load as cheerioload } from "cheerio";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
|
||||
export const id = "ANF.com";
|
||||
export const name = "AllNovelFull";
|
||||
export const site = "https://allnovelfull.com";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/allnovelfull/icon.png";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${site}/most-popular?page=${page}`;
|
||||
|
||||
const result = await fetchApi(url, {});
|
||||
if (!result.ok) {
|
||||
console.error("Cloudflare error");
|
||||
// console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
loadedCheerio(".col-truyen-main .list-truyen .row").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.text();
|
||||
const novelCover =
|
||||
site + loadedCheerio(this).find("img.cover").attr("src");
|
||||
const novelUrl =
|
||||
site + loadedCheerio(this).find("h3.truyen-title > a").attr("href");
|
||||
|
||||
const novel = {
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
};
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
console.error("Cloudflare error");
|
||||
// console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return { url, chapters: [] };
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("div.book > img").attr("alt");
|
||||
|
||||
novel.cover = site + 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: string) {
|
||||
const chapterListUrl = site + "/ajax/chapter-option?novelId=" + id;
|
||||
|
||||
const data = await fetchApi(chapterListUrl);
|
||||
if (!data.ok) {
|
||||
console.error("Cloudflare error");
|
||||
// console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const chapters = await data.text();
|
||||
|
||||
loadedCheerio = cheerioload(chapters);
|
||||
|
||||
const novelChapters: Chapter.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = site + chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
console.error("Cloudflare error");
|
||||
// console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return "Cloudflare protected site!";
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
const chapterText = loadedCheerio("#chapter-content").html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${site}/search?keyword=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.col-truyen-main > div.list-truyen > .row").each(
|
||||
function () {
|
||||
const novelUrl =
|
||||
site +
|
||||
loadedCheerio(this).find("h3.truyen-title > a").attr("href");
|
||||
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.text();
|
||||
const novelCover =
|
||||
site + loadedCheerio(this).find("img").attr("src");
|
||||
|
||||
if (novelUrl) {
|
||||
novels.push({
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url, init) {
|
||||
return await fetchFile(url, init);
|
||||
};
|
||||
|
||||
exports.protected = false;
|
||||
@@ -1,143 +0,0 @@
|
||||
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,172 @@
|
||||
import { load as cheerioload } from "cheerio";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
|
||||
export const id = "BLN.com";
|
||||
export const name = "BestLightNovel";
|
||||
export const site = "https://bestlightnovel.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/bestlightnovel/icon.png";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url =
|
||||
site + "novel_list?type=topview&category=all&state=all&page=1" + page;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection or other error
|
||||
return [];
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
console.error(await result.text());
|
||||
// TODO: Cloudflare protection
|
||||
return { url, chapters: [] };
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: NovelStatus.Unknown,
|
||||
genres: "",
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".truyen_info_right h1").text().trim();
|
||||
novel.cover =
|
||||
loadedCheerio(".info_image img").attr("src") || defaultCover;
|
||||
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"
|
||||
? NovelStatus.Ongoing
|
||||
: status === "COMPLETED"
|
||||
? NovelStatus.Completed
|
||||
: NovelStatus.Unknown;
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!chapterUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No chapter url!");
|
||||
return;
|
||||
}
|
||||
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
const chapterText = loadedCheerio("#vung_doc").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${site}search_novels/${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = (...args) => fetchFile(...args);
|
||||
|
||||
exports.protected = false;
|
||||
@@ -1,149 +0,0 @@
|
||||
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,164 @@
|
||||
import { load as cheerioload } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import dayjs from "dayjs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "comrademao";
|
||||
export const name = "Comrade Mao";
|
||||
export const site = "https://comrademao.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/comrademao/icon.png";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = site + "page/" + page + "/?post_type=novel";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novel: Novel.instance = { 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: Chapter.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!chapterUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No chapter url!");
|
||||
return;
|
||||
}
|
||||
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
url: chapterUrl,
|
||||
releaseTime: releaseDate,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
if (!result.ok) {
|
||||
const err = await result.text();
|
||||
console.error(err);
|
||||
// TODO: Cloudflare protection or other error
|
||||
return "Error!" + err;
|
||||
}
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let chapterText = loadedCheerio("#chaptercontent").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = site + "?s=" + searchTerm + "&post_type=novel";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!novelUrl) {
|
||||
// TODO: Handle error
|
||||
console.error("No novel url!");
|
||||
return;
|
||||
}
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = (...args) => fetchFile(...args);
|
||||
|
||||
exports.protected = false;
|
||||
@@ -1,155 +0,0 @@
|
||||
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,151 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export const id = "DDL.com";
|
||||
export const name = "Divine Dao Library";
|
||||
export const site = "https://www.divinedaolibrary.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/`en/divinedaolibrary/icon.png";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = baseUrl + "novels";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#main")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find(" a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = { url };
|
||||
|
||||
novel.name = loadedCheerio("h1.entry-title").text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio(".entry-content").find("img").attr("data-ezsrc") ||
|
||||
defaultCover;
|
||||
|
||||
novel.summary = loadedCheerio("#main > article > div > p:nth-child(6)")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = loadedCheerio("#main > article > div > h3:nth-child(2)")
|
||||
.text()
|
||||
.replace(/Author:/g, "")
|
||||
.trim();
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("#main")
|
||||
.find("li > span > a")
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
novelChapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(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;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
let url = baseUrl + "novels";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#main")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find(" a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
novels = novels.filter((novel) =>
|
||||
novel.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = async function (url, init) {
|
||||
return await fetchFile(url, init);
|
||||
};
|
||||
@@ -0,0 +1,196 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { showToast } from "@libs/showToast";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export const id = "earlynovel";
|
||||
export const name = "Early Novel";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "multisrc/madara/icons/latestnovel.png";
|
||||
export const site = "https://earlynovel.net/";
|
||||
module.exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}most-popular?page=${page}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".col-truyen-main > .list-truyen > .row").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.attr("title");
|
||||
const novelCover =
|
||||
loadedCheerio(this).find(".lazyimg").attr("data-desk-image") ||
|
||||
loadedCheerio(this).find("img.cover").attr("src");
|
||||
const novelUrl =
|
||||
baseUrl +
|
||||
loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.attr("href")
|
||||
?.slice(1);
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover || defaultCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
showToast("Early Novel may take 20-30 seconds");
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const name = loadedCheerio(".book > img").attr("alt");
|
||||
const cover = loadedCheerio(".book > img").attr("src") || defaultCover;
|
||||
const summary = loadedCheerio(".desc-text").text().trim();
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
name,
|
||||
summary,
|
||||
cover,
|
||||
};
|
||||
|
||||
loadedCheerio(".info > div > h3").each(function () {
|
||||
let detailName = loadedCheerio(this).text();
|
||||
let detail = loadedCheerio(this)
|
||||
.siblings()
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
switch (detailName) {
|
||||
case "Author:":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status:":
|
||||
novel.status = detail;
|
||||
break;
|
||||
case "Genre:":
|
||||
novel.genres = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//! Doesn't work since there are multiple pages and can't find source API
|
||||
//# Since cannot find sourceAPI i try similar function to lightnovelpub
|
||||
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
const lastPageStr = loadedCheerio('a:contains("Last ")')
|
||||
.attr("title")
|
||||
?.match(/(\d+)/g);
|
||||
const lastPage = Number(lastPageStr?.[1] || "0");
|
||||
|
||||
async function getChapters() {
|
||||
let chapter: Chapter.Item[] = [];
|
||||
for (let i = 1; i <= lastPage; i++) {
|
||||
const chaptersUrl = `${novelUrl}?page=${i}`;
|
||||
|
||||
const chaptersHtml = await fetchApi(
|
||||
chaptersUrl,
|
||||
{},
|
||||
pluginId
|
||||
).then((r) => r.text());
|
||||
|
||||
loadedCheerio = parseHTML(chaptersHtml);
|
||||
|
||||
loadedCheerio("ul.list-chapter > li").each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find(".chapter-text")
|
||||
.text()
|
||||
.trim();
|
||||
const releaseDate = null;
|
||||
const chapterHref = loadedCheerio(this)
|
||||
.find("a")
|
||||
.attr("href")
|
||||
?.slice(1);
|
||||
if (!chapterHref) return;
|
||||
const chapterUrl = baseUrl + chapterHref;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
await delay(1000);
|
||||
}
|
||||
|
||||
return chapter;
|
||||
}
|
||||
|
||||
novel.chapters = await getChapters();
|
||||
|
||||
return novel;
|
||||
};
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#chapter-c").html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search?keyword=${searchTerm}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function fetchImage(url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,168 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "fastnovel";
|
||||
export const name = "Fast Novel";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/fastnovel/icon.png";
|
||||
export const site = "https://fastnovel.org/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}sort/p/?page=${page}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".col-novel-main .list-novel .row").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3.novel-title > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img.cover").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find("h3.novel-title > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("div.book > img").attr("alt");
|
||||
|
||||
novel.cover = loadedCheerio("div.book > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio("div.desc-text").text().trim();
|
||||
|
||||
loadedCheerio("ul.info > li > h3").each(function () {
|
||||
let detailName = loadedCheerio(this).text();
|
||||
let detail = loadedCheerio(this)
|
||||
.siblings()
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
switch (detailName) {
|
||||
case "Author:":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status:":
|
||||
novel.status = detail;
|
||||
break;
|
||||
case "Genre:":
|
||||
novel.genres = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
const novelId = loadedCheerio("#rating").attr("data-novel-id");
|
||||
|
||||
async function getChapters(id: string) {
|
||||
const chapterListUrl =
|
||||
baseUrl + "ajax/chapter-archive?novelId=" + id;
|
||||
|
||||
const data = await fetchApi(chapterListUrl);
|
||||
const chapterdata = await data.text();
|
||||
|
||||
loadedCheerio = parseHTML(chapterdata);
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("ul.list-chapter > li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").attr("title");
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterName || !chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
return chapter;
|
||||
}
|
||||
|
||||
if (novelId) {
|
||||
novel.chapters = await getChapters(novelId);
|
||||
}
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('#chr-content > div,h6,p[style="display: none;"]').remove();
|
||||
let chapterText = loadedCheerio("#chr-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search/?keyword=${searchTerm}`;
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.col-novel-main > div.list-novel > .row").each(
|
||||
function () {
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find("h3.novel-title > a")
|
||||
.attr("href");
|
||||
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3.novel-title > a")
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
|
||||
if (novelUrl) {
|
||||
novels.push({
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -1,162 +0,0 @@
|
||||
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,170 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "foxaholic";
|
||||
export const name = "Foxaholic";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/foxaholic/icon.png";
|
||||
export const site = "https://www.foxaholic.com/";
|
||||
module.exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const link = `${baseUrl}novel/page/${page}/?m_orderby=rating`;
|
||||
|
||||
const result = await fetchApi(link, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".h5 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("data-src");
|
||||
const novelUrl = loadedCheerio(this).find(".h5 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".post-title > h1").text().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()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this).find(".summary-content").html();
|
||||
|
||||
if (!detail) return;
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre":
|
||||
novel.genres = loadedCheerio(detail)
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
break;
|
||||
case "Author":
|
||||
novel.author = loadedCheerio(detail)
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(", ");
|
||||
break;
|
||||
case "Novel":
|
||||
novel.status = detail?.trim().replace(/G/g, "g");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio(
|
||||
".description-summary > div.summary__content > div"
|
||||
).remove();
|
||||
|
||||
novel.summary = loadedCheerio(
|
||||
".description-summary > div.summary__content"
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find("a")
|
||||
.text()
|
||||
.replace(/[\t\n]/g, "")
|
||||
.trim();
|
||||
const releaseDate = loadedCheerio(this).find("span").text().trim();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("img").removeAttr("srcset");
|
||||
let chapterText = loadedCheerio(".reading-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}&post_type=wp-manga`;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
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");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { showToast } from "@libs/showToast";
|
||||
import { isUrlAbsolute } from "@libs/isAbsoluteUrl";
|
||||
import { Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "freenovelupdates";
|
||||
export const name = "Free Novel Updates (Broken)";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/freenovelupdates/icon.png";
|
||||
export const site = "https://www.freenovelupdates.com";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}genres/light-novel-1002`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".books-item").each(function () {
|
||||
let novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (novelUrl && !isUrlAbsolute(novelUrl)) {
|
||||
novelUrl = baseUrl + novelUrl;
|
||||
}
|
||||
|
||||
if (novelUrl) {
|
||||
const novelName = loadedCheerio(this).find(".title").text().trim();
|
||||
let novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
|
||||
if (novelCover && !isUrlAbsolute(novelCover)) {
|
||||
novelCover = baseUrl + novelCover;
|
||||
}
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1").text();
|
||||
|
||||
let novelCover = loadedCheerio(".img > img").attr("src");
|
||||
|
||||
novel.cover = novelCover
|
||||
? isUrlAbsolute(novelCover)
|
||||
? novelCover
|
||||
: baseUrl + novelCover
|
||||
: undefined;
|
||||
|
||||
novel.summary = loadedCheerio(".description-content").text().trim();
|
||||
|
||||
novel.author = loadedCheerio(".author").text().trim();
|
||||
|
||||
novel.genres = loadedCheerio(".category").text().trim();
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
loadedCheerio(".chapter").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;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".content").html() || "";
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
showToast("Search is not available in this source");
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -1,173 +0,0 @@
|
||||
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,166 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "FWN.com";
|
||||
export const name = "Web NOVEL";
|
||||
export const site = "https://freewebnovel.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/freewebnovel/icon.png";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = baseUrl + "completed-novel/" + page;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
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.status = loadedCheerio("[title=Status]")
|
||||
.next()
|
||||
.text()
|
||||
.replace(/[\t\n]/g, "");
|
||||
|
||||
let novelSummary = loadedCheerio(".inner").text().trim();
|
||||
novel.summary = novelSummary;
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
let latestChapter: string | undefined;
|
||||
|
||||
loadedCheerio("h3.tit").each(function (res) {
|
||||
if (loadedCheerio(this).find("a").text() === novel.name) {
|
||||
latestChapter = loadedCheerio(this)
|
||||
.next()
|
||||
.find("span.s3")
|
||||
.text()
|
||||
.match(/(\d+)/)?.[0];
|
||||
}
|
||||
});
|
||||
|
||||
let prefixUrl = novelUrl.replace(".html", "/");
|
||||
|
||||
for (let i = 1; i <= parseInt(latestChapter || "0", 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;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio("div.txt").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = baseUrl + "search/";
|
||||
|
||||
const formData = {
|
||||
searchkey: searchTerm,
|
||||
};
|
||||
|
||||
const result = await fetchApi(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(formData),
|
||||
});
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,213 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "lightnovelpub";
|
||||
export const name = "LightNovelPub";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/lightnovelpub/icon.png";
|
||||
export const site = "https://www.lightnovelpub.com/";
|
||||
exports.protected = true;
|
||||
|
||||
const baseUrl = site;
|
||||
const pluginId = id;
|
||||
|
||||
const headers = {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}browse/all/popular/all/${page}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1.novel-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio("figure.cover > img").attr("data-src");
|
||||
|
||||
novel.genres = "";
|
||||
|
||||
loadedCheerio(".categories > ul > li > a").each(function () {
|
||||
novel.genres += loadedCheerio(this).text() + ",";
|
||||
});
|
||||
|
||||
novel.genres = novel.genres.slice(0, -1);
|
||||
|
||||
loadedCheerio("div.header-stats > span").each(function () {
|
||||
if (loadedCheerio(this).find("small").text() === "Status") {
|
||||
novel.status = loadedCheerio(this).find("strong").text();
|
||||
}
|
||||
});
|
||||
|
||||
novel.author = loadedCheerio(".author > a > span").text();
|
||||
|
||||
novel.summary = loadedCheerio(".summary > .content").text().trim();
|
||||
|
||||
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
let lastPage = 1;
|
||||
|
||||
lastPage = parseInt(
|
||||
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);
|
||||
|
||||
async function getChapters() {
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
for (let i = 1; i <= lastPage; i++) {
|
||||
const chaptersUrl = `${novelUrl}/chapters/page-${i}`;
|
||||
|
||||
const chaptersHtml = await fetchApi(
|
||||
chaptersUrl,
|
||||
{ headers: headers },
|
||||
pluginId
|
||||
).then((r) => r.text());
|
||||
|
||||
loadedCheerio = parseHTML(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);
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
await delay(1000);
|
||||
}
|
||||
|
||||
return chapter;
|
||||
}
|
||||
|
||||
novel.chapters = await getChapters();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio("#chapter-container").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}lnsearchlive`;
|
||||
const link = `${baseUrl}search`;
|
||||
const response = await fetchApi(link, {}, pluginId).then((r) => r.text());
|
||||
const token = parseHTML(response);
|
||||
let verifytoken = token("#novelSearchForm > input").attr("value");
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("inputContent", searchTerm);
|
||||
|
||||
const body = await fetchApi(
|
||||
url,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { LNRequestVerifyToken: verifytoken! },
|
||||
body: formData,
|
||||
},
|
||||
pluginId
|
||||
).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
let results = JSON.parse(loadedCheerio("body").text());
|
||||
|
||||
loadedCheerio = parseHTML(results.resultview);
|
||||
|
||||
loadedCheerio(".novel-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h4.novel-title")
|
||||
.text()
|
||||
.trim();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find("a").attr("href")?.substring(1);
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,161 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "LightNovelUpdates";
|
||||
export const name = "Light Novel Updates";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/lightnovelupdates/icon.png";
|
||||
export const site = "https://www.lightnovelupdates.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = `${baseUrl}novel/page/${page}/?m_orderby=rating`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".h5 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find(".h5 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".post-title > h1").text().trim();
|
||||
novel.cover =
|
||||
loadedCheerio(".summary_image > a > img").attr("src") || undefined;
|
||||
|
||||
loadedCheerio(".post-content_item").each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find(".summary-heading > h5")
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Genre(s)":
|
||||
novel.genres = detail.trim().replace(/[\t\n]/g, ",");
|
||||
break;
|
||||
case "Author(s)":
|
||||
novel.author = detail.trim();
|
||||
break;
|
||||
case "Status":
|
||||
novel.status = detail.replace(/G/g, "g");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.summary = loadedCheerio("div.summary__content").text();
|
||||
|
||||
const chapter: Chapter.Item[] = [];
|
||||
|
||||
const novelId = loadedCheerio(".rating-post-id").attr("value")!;
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("action", "manga_get_chapters");
|
||||
formData.append("manga", novelId);
|
||||
|
||||
const data = await fetchApi(
|
||||
"https://www.lightnovelupdates.com/wp-admin/admin-ajax.php",
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
},
|
||||
pluginId
|
||||
);
|
||||
const text = await data.text();
|
||||
|
||||
loadedCheerio = parseHTML(text);
|
||||
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = loadedCheerio(this).find("span").text().trim();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const chapterText = (await NovelUpdatesScraper.parseChapter(chapterUrl))
|
||||
.chapterText;
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}&post_type=wp-manga&m_orderby=rating`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".h4 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find(".h4 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
url: novelUrl,
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,183 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { showToast } from "@libs/showToast";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
const pluginId = "lnmtl";
|
||||
const baseUrl = "https://lnmtl.com/";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = baseUrl + "novel?page=" + page;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".media").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h4").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h4 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
showToast("LNMTL might take around 20-30 seconds.");
|
||||
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".novel-name").text();
|
||||
|
||||
novel.cover = loadedCheerio("div.novel").find("img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio("div.description").text().trim();
|
||||
|
||||
loadedCheerio(".panel-body > dl").each(function () {
|
||||
let detailName = loadedCheerio(this).find("dt").text().trim();
|
||||
let detail = loadedCheerio(this).find("dd").text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Authors":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Current status":
|
||||
novel.status = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = loadedCheerio('.panel-heading:contains(" Genres ")')
|
||||
.next()
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/\s\s/g, ",");
|
||||
|
||||
let volumes = JSON.parse(
|
||||
loadedCheerio("main")
|
||||
.next()
|
||||
.html()
|
||||
.match(/lnmtl.volumes = \[(.*?)\]/).[0]
|
||||
.replace("lnmtl.volumes = ", "")
|
||||
);
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
volumes = volumes.map((volume) => volume.id);
|
||||
|
||||
for (const volume of volumes) {
|
||||
let volumeData = await fetchApi(
|
||||
`https://lnmtl.com/chapter?page=1&volumeId=${volume}`
|
||||
);
|
||||
volumeData = await volumeData.json();
|
||||
|
||||
// volumeData = volumeData.data.map((volume) => volume.slug);
|
||||
|
||||
for (let i = 1; i <= volumeData.last_page; i++) {
|
||||
let chapterData = await fetchApi(
|
||||
`https://lnmtl.com/chapter?page=${i}&volumeId=${volume}`
|
||||
);
|
||||
chapterData = await chapterData.json();
|
||||
|
||||
chapterData = chapterData.data.map((chapter) => ({
|
||||
name: `#${chapter.number} ${chapter.title}`,
|
||||
url: `${baseUrl}chapter/${chapter.slug}`,
|
||||
releaseTime: chapter.created_at,
|
||||
}));
|
||||
|
||||
chapters.push(...chapterData);
|
||||
}
|
||||
}
|
||||
|
||||
novel.chapters = chapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".original").replaceWith("<br><br>");
|
||||
|
||||
let chapterText = loadedCheerio(".chapter-body").html();
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = loadedCheerio(".alert.alert-warning").text();
|
||||
}
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = "https://lnmtl.com/term";
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels:Novel.Item[] = loadedCheerio("footer")
|
||||
.next()
|
||||
.next()
|
||||
.html()
|
||||
.match(/local: \[(.*?)\]/)[0]
|
||||
.replace("local: ", "");
|
||||
|
||||
novels = JSON.parse(novels);
|
||||
|
||||
novels = novels.filter((novel) =>
|
||||
novel.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
novels = novels.map((novel) => ({
|
||||
name: novel.name,
|
||||
url: novel.slug,
|
||||
cover: novel.image,
|
||||
}));
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: "LNMTL",
|
||||
version: "1.0.0",
|
||||
icon: "src/en/lnmtl/icon.png",
|
||||
site: baseUrl,
|
||||
protected: true,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
};
|
||||
@@ -0,0 +1,180 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
const pluginId = "mtlnovel";
|
||||
const baseUrl = "https://www.mtlnovel.com/";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}alltime-rank/page/${page}`;
|
||||
|
||||
const headers = {
|
||||
Referer: `${baseUrl}`,
|
||||
"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",
|
||||
};
|
||||
|
||||
const body = await fetchApi(
|
||||
url,
|
||||
{
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
},
|
||||
pluginId
|
||||
).then((result) => result.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.box.wide").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("a.list-title")
|
||||
.text()
|
||||
.slice(4);
|
||||
const novelCover = loadedCheerio(this).find("amp-img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("a.list-title").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
let headers = {
|
||||
Referer: `${baseUrl}alltime-rank/`,
|
||||
"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",
|
||||
};
|
||||
|
||||
const body = await fetchApi(
|
||||
url,
|
||||
{
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
},
|
||||
pluginId
|
||||
).then((result) => result.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1.entry-title").text();
|
||||
|
||||
novel.cover = loadedCheerio(".nov-head > amp-img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio("div.desc > h2").next().text().trim();
|
||||
|
||||
novel.author = loadedCheerio("#author").text();
|
||||
|
||||
novel.status = loadedCheerio("#status").text();
|
||||
|
||||
novel.genres = loadedCheerio("#genre").text().replace(/\s+/g, "");
|
||||
|
||||
const chapterListUrl = url + "chapter-list/";
|
||||
|
||||
async function getChapters() {
|
||||
const listResult = await fetch(chapterListUrl);
|
||||
const listBody = await listResult.text();
|
||||
|
||||
loadedCheerio = parseHTML(listBody);
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("div.ch-list")
|
||||
.find("a.ch-link")
|
||||
.each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.text()
|
||||
.replace("~ ", "");
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).attr("href");
|
||||
|
||||
chapter.push({
|
||||
url: chapterUrl,
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
});
|
||||
});
|
||||
return chapter.reverse();
|
||||
}
|
||||
|
||||
novel.chapters = await getChapters();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("div.par").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const searchUrl =
|
||||
baseUrl +
|
||||
"wp-admin/admin-ajax.php?action=autosuggest&q=" +
|
||||
searchTerm +
|
||||
"&__amp_source_origin=https%3A%2F%2Fwww.mtlnovel.com";
|
||||
|
||||
const res = await fetch(searchUrl);
|
||||
const result = await res.json();
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
result.items[0].results.map((item) => {
|
||||
const novelName = item.title.replace(/<\/?strong>/g, "");
|
||||
const novelCover = item.thumbnail;
|
||||
const novelUrl = item.permalink.replace(
|
||||
"https://www.mtlnovel.com/",
|
||||
""
|
||||
);
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: "MTL Novel",
|
||||
version: "1.0.0",
|
||||
icon: "src/en/mtlnovel/icon.png",
|
||||
site: baseUrl,
|
||||
protected: false,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
};
|
||||
@@ -0,0 +1,133 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "mtlreader";
|
||||
export const name = "MTL Reader";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/mtlreader/icon.png";
|
||||
export const site = "https://mtlreader.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}novels?page=${page}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".col-md-4.col-sm-4").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h5").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h5 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".agent-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".agent-p-img > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio("#editdescription").text().trim();
|
||||
|
||||
novel.author = loadedCheerio("i.fa-user")
|
||||
.parent()
|
||||
.text()
|
||||
.replace("Author: ", "")
|
||||
.trim();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("tr.spaceUnder").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio(".container ins,script,p.mtlreader").remove();
|
||||
const chapterText = loadedCheerio(".container").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search?input=${searchTerm}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".col-md-4.col-sm-4").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h5").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h5 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "nitroscans";
|
||||
export const name = "Nitroscans";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/nitroscans/icon.png";
|
||||
export const site = "https://nitroscans.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = baseUrl + "wp-admin/admin-ajax.php";
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("action", "madara_load_more");
|
||||
formData.append("page", `${Number(page - 1)}`);
|
||||
formData.append("template", "madara-core/content/content-archive");
|
||||
formData.append("vars[orderby]", "meta_value_num");
|
||||
formData.append("vars[post_type]", "wp-manga");
|
||||
formData.append("vars[meta_key]", "_wp_manga_views");
|
||||
formData.append("vars[wp-manga-genre]", "novels");
|
||||
|
||||
const body = await fetchApi(url, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".page-item-detail").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("data-src");
|
||||
const novelUrl = loadedCheerio(this).find("h3 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
loadedCheerio(".manga-title-badges.custom.novel").remove();
|
||||
|
||||
novel.name = loadedCheerio(".post-title > h1").text().trim();
|
||||
novel.cover = loadedCheerio(".summary_image")
|
||||
.find("img")
|
||||
.attr("data-src");
|
||||
|
||||
novel.summary = loadedCheerio(".summary__content").text()?.trim();
|
||||
|
||||
novel.genres = loadedCheerio(".genres-content")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
loadedCheerio(".post-content_item").each(function () {
|
||||
const detailName = loadedCheerio(this)
|
||||
.find(".summary-heading")
|
||||
.text()
|
||||
.trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find(".summary-content")
|
||||
.text()
|
||||
.trim();
|
||||
switch (detailName) {
|
||||
case "Author(s)":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status":
|
||||
novel.status = detail.replace(/G/g, "g");
|
||||
break;
|
||||
}
|
||||
});
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
let chapterlisturl = novelUrl + "ajax/chapters/";
|
||||
|
||||
const data = await fetchApi(chapterlisturl, { method: "POST" });
|
||||
const text = await data.text();
|
||||
|
||||
loadedCheerio = parseHTML(text);
|
||||
|
||||
loadedCheerio(".wp-manga-chapter").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = loadedCheerio(this).find("span").text().trim();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".text-left").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = baseUrl + "wp-admin/admin-ajax.php";
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("action", "madara_load_more");
|
||||
formData.append("page", `${Number(1 - 1)}`);
|
||||
formData.append("template", "madara-core/content/content-search");
|
||||
formData.append("vars[s]", searchTerm);
|
||||
formData.append("vars[post_type]", "wp-manga");
|
||||
formData.append("vars[wp-manga-genre]", "novels");
|
||||
|
||||
const body = await fetchApi(url, {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".c-tabs-item__content").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h3 > a").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("data-src");
|
||||
const novelUrl = loadedCheerio(this).find("h3 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,416 @@
|
||||
import { load as cheerioload } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { Filter, FilterInputs } from "@libs/filterInputs";
|
||||
|
||||
export const id = "NobleMTL";
|
||||
export const name = "NobleMTL";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/noblemtl/icon.png";
|
||||
export const site = "https://www.noblemtl.com/";
|
||||
exports.protected = false;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters }
|
||||
) {
|
||||
let link = `${site}series/?page=${page}`;
|
||||
|
||||
if (filters?.genres?.length) {
|
||||
if (Array.isArray(filters.genres))
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (filters?.type?.length) {
|
||||
if (Array.isArray(filters.type))
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
|
||||
link += "&status=" + (filters?.status ? filters?.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters?.order : "popular");
|
||||
|
||||
const body = await fetchApi(link).then((result) => result.text());
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.bs").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".ntitle").text().trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function parseNovelAndChapters(novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerioload(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".entry-title").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
|
||||
loadedCheerio("div.spe > span").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find("b")
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "المؤلف:":
|
||||
case "Yazar:":
|
||||
case "Autor:":
|
||||
case "Author:":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status:":
|
||||
case "Seviye:":
|
||||
novel.status = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = loadedCheerio(".genxed")
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/\s/g, ",");
|
||||
|
||||
loadedCheerio('div[itemprop="description"] h3,p.a,strong').remove();
|
||||
novel.summary = loadedCheerio('div[itemprop="description"]')
|
||||
.find("br")
|
||||
.replaceWith("\n")
|
||||
.end()
|
||||
.text();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".eplister")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const chapterName =
|
||||
loadedCheerio(this).find(".epl-num").text() +
|
||||
" - " +
|
||||
loadedCheerio(this).find(".epl-title").text();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find(".epl-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
let chapterText = loadedCheerio("div.epcontent").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${site}?s=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerioload(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.bs").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".ntitle").text().trim();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: site,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
export const filters: Filter[] = [
|
||||
{
|
||||
key: "order",
|
||||
label: "Sort By",
|
||||
values: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
|
||||
{ label: "Latest Update", value: "update" },
|
||||
|
||||
{ label: "Latest Added", value: "latest" },
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
label: "Status",
|
||||
values: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
|
||||
{ label: "Hiatus", value: "hiatus" },
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
label: "Type",
|
||||
values: [
|
||||
{ label: "Chinese novel", value: "chinese-novel" },
|
||||
|
||||
{ label: "habyeol", value: "habyeol" },
|
||||
|
||||
{ label: "korean novel", value: "korean-novel" },
|
||||
|
||||
{ label: "Web Novel", value: "web-novel" },
|
||||
|
||||
{ label: "삼심", value: "%ec%82%bc%ec%8b%ac" },
|
||||
|
||||
{ label: "호곡", value: "%ed%98%b8%ea%b3%a1" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
label: "Genres",
|
||||
values: [
|
||||
{ label: "A.I", value: "a.i" },
|
||||
|
||||
{ label: "Academy", value: "academy" },
|
||||
|
||||
{ label: "Action", value: "action" },
|
||||
|
||||
{ label: "Adult", value: "adult" },
|
||||
|
||||
{ label: "Adventure", value: "adventure" },
|
||||
|
||||
{ label: "Alternative History", value: "alternative-history" },
|
||||
|
||||
{ label: "Another World", value: "another-world" },
|
||||
|
||||
{ label: "Apocalypse", value: "apocalypse" },
|
||||
|
||||
{ label: "Bromance", value: "bromance" },
|
||||
|
||||
{ label: "Comedy", value: "comedy" },
|
||||
|
||||
{ label: "Dark fantasy", value: "dark-fantasy" },
|
||||
|
||||
{ label: "Demons", value: "demons" },
|
||||
|
||||
{ label: "Drama", value: "drama" },
|
||||
|
||||
{ label: "Dystopia", value: "dystopia" },
|
||||
|
||||
{ label: "Ecchi", value: "ecchi" },
|
||||
|
||||
{ label: "Entertainment", value: "entertainment" },
|
||||
|
||||
{ label: "Exhaustion", value: "exhaustion" },
|
||||
|
||||
{ label: "Fanfiction", value: "fanfiction" },
|
||||
|
||||
{ label: "fantasy", value: "fantasy" },
|
||||
|
||||
{ label: "finance", value: "finance" },
|
||||
|
||||
{ label: "Full color", value: "full-color" },
|
||||
|
||||
{ label: "Game", value: "game" },
|
||||
|
||||
{ label: "Gender Bender", value: "gender-bender" },
|
||||
|
||||
{ label: "Genius", value: "genius" },
|
||||
|
||||
{ label: "Harem", value: "harem" },
|
||||
|
||||
{ label: "Hero", value: "hero" },
|
||||
|
||||
{ label: "Historical", value: "historical" },
|
||||
|
||||
{ label: "Hunter", value: "hunter" },
|
||||
|
||||
{ label: "korean novel", value: "korean-novel" },
|
||||
|
||||
{ label: "Light Novel", value: "light-novel" },
|
||||
|
||||
{
|
||||
label: "List Adventure Manga Genres",
|
||||
value: "list-adventure-manga-genres",
|
||||
},
|
||||
|
||||
{ label: "Long Strip", value: "long-strip" },
|
||||
|
||||
{ label: "Love comedy", value: "love-comedy" },
|
||||
|
||||
{ label: "magic", value: "magic" },
|
||||
|
||||
{ label: "Manhua", value: "manhua" },
|
||||
|
||||
{ label: "Martial Arts", value: "martial-arts" },
|
||||
|
||||
{ label: "Mature", value: "mature" },
|
||||
|
||||
{ label: "Medieval", value: "medieval" },
|
||||
|
||||
{ label: "Misunderstanding", value: "misunderstanding" },
|
||||
|
||||
{ label: "Modern", value: "modern" },
|
||||
|
||||
{ label: "modern fantasy", value: "modern-fantasy" },
|
||||
|
||||
{ label: "music", value: "music" },
|
||||
|
||||
{ label: "Mystery", value: "mystery" },
|
||||
|
||||
{ label: "Necromancy", value: "necromancy" },
|
||||
|
||||
{ label: "No Romance", value: "no-romance" },
|
||||
|
||||
{ label: "NTL", value: "ntl" },
|
||||
|
||||
{ label: "o", value: "o" },
|
||||
|
||||
{ label: "Obsession", value: "obsession" },
|
||||
|
||||
{ label: "Politics", value: "politics" },
|
||||
|
||||
{ label: "Possession", value: "possession" },
|
||||
|
||||
{ label: "Programming", value: "programming" },
|
||||
|
||||
{ label: "Psychological", value: "psychological" },
|
||||
|
||||
{ label: "Pure Love", value: "pure-love" },
|
||||
|
||||
{ label: "Redemption", value: "redemption" },
|
||||
|
||||
{ label: "Regression", value: "regression" },
|
||||
|
||||
{ label: "Regret", value: "regret" },
|
||||
|
||||
{ label: "Reincarnation", value: "reincarnation" },
|
||||
|
||||
{ label: "Revenge", value: "revenge" },
|
||||
|
||||
{ label: "Romance", value: "romance" },
|
||||
|
||||
{ label: "Romance Fanrasy", value: "romance-fanrasy" },
|
||||
|
||||
{ label: "Salvation", value: "salvation" },
|
||||
|
||||
{ label: "School Life", value: "school-life" },
|
||||
|
||||
{ label: "Sci-fi", value: "sci-fi" },
|
||||
|
||||
{ label: "Science fiction", value: "science-fiction" },
|
||||
|
||||
{ label: "Seinen", value: "seinen" },
|
||||
|
||||
{ label: "Shounen", value: "shounen" },
|
||||
|
||||
{ label: "Slice of Life", value: "slice-of-life" },
|
||||
|
||||
{ label: "Soft yandere", value: "soft-yandere" },
|
||||
|
||||
{ label: "Sports", value: "sports" },
|
||||
|
||||
{ label: "Supernatural", value: "supernatural" },
|
||||
|
||||
{ label: "Survival", value: "survival" },
|
||||
|
||||
{ label: "system", value: "system" },
|
||||
|
||||
{ label: "Time limit", value: "time-limit" },
|
||||
|
||||
{ label: "Tragedy", value: "tragedy" },
|
||||
|
||||
{ label: "Transmigration", value: "transmigration" },
|
||||
|
||||
{ label: "TS", value: "ts" },
|
||||
|
||||
{ label: "Tsundere", value: "tsundere" },
|
||||
|
||||
{ label: "Unique", value: "unique" },
|
||||
|
||||
{ label: "Wholesome", value: "wholesome" },
|
||||
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
|
||||
{ label: "Xuanhuan", value: "xuanhuan" },
|
||||
|
||||
{ label: "Yandere", value: "yandere" },
|
||||
|
||||
{ label: "Yuri", value: "yuri" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,167 @@
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
|
||||
export const id = "novelforest";
|
||||
export const name = "Novel Forest (Broken)";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/novelforest/icon.png";
|
||||
export const site = "https://novelforest.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}popular?page=${page}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
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 = 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.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(2) > 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(3)"
|
||||
)
|
||||
.text()
|
||||
?.replace("Genres :", "")
|
||||
.replace(/[\s\n]+/g, " ")
|
||||
.trim();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
const chaptersUrl =
|
||||
novelUrl.replace(baseUrl, "https://novelforest.com/api/novels/") +
|
||||
"/chapters?source=detail";
|
||||
|
||||
const chaptersRequest = await fetch(chaptersUrl);
|
||||
const chaptersHtml = await chaptersRequest.text();
|
||||
|
||||
loadedCheerio = parseHTML(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 =
|
||||
baseUrl + loadedCheerio(this).find("a").attr("href")?.substring(1);
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("#listen-chapter").remove();
|
||||
loadedCheerio("#google_translate_element").remove();
|
||||
|
||||
const chapterText = loadedCheerio(".chapter__content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search?q=${searchTerm}`;
|
||||
|
||||
const body = await fetchApi(url, {}, pluginId).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,172 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "novelfull";
|
||||
export const name = "NovelFull";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/novelfull/icon.png";
|
||||
export const site = "https://novelfull.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}most-popular?page=${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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").attr("src")?.slice(1);
|
||||
|
||||
const novelUrl =
|
||||
baseUrl +
|
||||
loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.attr("href")
|
||||
?.slice(1);
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
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('h3:contains("Author")')
|
||||
.parent()
|
||||
.contents()
|
||||
.text()
|
||||
.replace("Author:", "");
|
||||
|
||||
novel.genres = loadedCheerio('h3:contains("Genre")')
|
||||
.siblings()
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
novel.status = loadedCheerio('h3:contains("Status")').next().text();
|
||||
|
||||
const novelId = loadedCheerio("#rating").attr("data-novel-id")!;
|
||||
|
||||
async function getChapters(id: string) {
|
||||
const chapterListUrl =
|
||||
baseUrl + "ajax/chapter-option?novelId=" + id;
|
||||
|
||||
const data = await fetchApi(chapterListUrl);
|
||||
const chapterlist = await data.text();
|
||||
|
||||
loadedCheerio = parseHTML(chapterlist);
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("select > option").each(function () {
|
||||
const chapterName = loadedCheerio(this).text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl =
|
||||
baseUrl + loadedCheerio(this).attr("value")?.slice(1);
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
return chapter;
|
||||
}
|
||||
|
||||
novel.chapters = await getChapters(novelId);
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("#chapter-content div.ads").remove();
|
||||
let chapterText = loadedCheerio("#chapter-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const searchUrl = `${baseUrl}search?keyword=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(searchUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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").attr("src")?.slice(1);
|
||||
|
||||
const novelUrl =
|
||||
baseUrl +
|
||||
loadedCheerio(this)
|
||||
.find("h3.truyen-title > a")
|
||||
.attr("href")
|
||||
?.slice(1);
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -0,0 +1,148 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "novelhold";
|
||||
export const name = "Novel Hold";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/novelhold/icon.png";
|
||||
export const site = "https://novelhold.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}all-${page}.html`;
|
||||
|
||||
const body = await fetchApi(url).then((r) => r.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#article_list_content > li").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3")
|
||||
.text()
|
||||
.replace(/\t+/g, "")
|
||||
.replace(/\n/g, " ");
|
||||
const novelCover = loadedCheerio(this).find("img").attr("data-src");
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find("a").attr("href")?.slice(1);
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const body = await fetchApi(url).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".booknav2 > h1").text();
|
||||
|
||||
novel.cover = loadedCheerio('meta[property="og:image"]').attr(
|
||||
"content"
|
||||
);
|
||||
|
||||
novel.summary = loadedCheerio(".navtxt").text().trim();
|
||||
|
||||
novel.author = loadedCheerio('p:contains("Author")')
|
||||
.text()
|
||||
.replace("Author:", "")
|
||||
.trim();
|
||||
|
||||
novel.status = loadedCheerio('p:contains("Status")')
|
||||
.text()
|
||||
.replace("Status:", "")
|
||||
.replace("Active", "Ongoing")
|
||||
.trim();
|
||||
|
||||
novel.genres = loadedCheerio('p:contains("Genre")')
|
||||
.text()
|
||||
?.replace("Genre:", "")
|
||||
.trim();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("ul.chapterlist > li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl =
|
||||
baseUrl + loadedCheerio(this).find("a").attr("href")?.slice(1);
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter;
|
||||
console.log(novel);
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const body = await fetchApi(chapterUrl).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}index.php?s=so&module=book&keyword=${searchTerm}`;
|
||||
|
||||
const body = await fetchApi(url).then((r) => r.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#article_list_content > li").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find("h3")
|
||||
.text()
|
||||
.replace(/\t+/g, "")
|
||||
.replace(/\n/g, " ");
|
||||
const novelCover = loadedCheerio(this).find("img").attr("data-src");
|
||||
const novelUrl =
|
||||
baseUrl + loadedCheerio(this).find("a").attr("href")?.slice(1);
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -1,182 +0,0 @@
|
||||
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,
|
||||
};
|
||||
@@ -0,0 +1,189 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "novelpub.com";
|
||||
export const name = "NovelPub";
|
||||
export const site = "https://www.novelpub.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/novelpub/icon.png";
|
||||
const baseUrl = site;
|
||||
|
||||
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",
|
||||
};
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = baseUrl + "browse/all/popular/all/" + page;
|
||||
|
||||
const result = await fetchApi(url, { method: "GET", headers });
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, { method: "GET", headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = { 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: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
let lastPage = 1;
|
||||
|
||||
lastPage = parseInt(
|
||||
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: Chapter.Item[] = [];
|
||||
|
||||
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 = parseHTML(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;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url, { method: "GET", headers });
|
||||
|
||||
const body = await result.text();
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#chapter-container").html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
// They have API to search, pls update it, im quite lazy xD
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}lnwsearchlive?inputContent=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url, { method: "GET", headers });
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
// let results = JSON.parse(loadedCheerio('body').text());
|
||||
|
||||
// loadedCheerio = 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;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,492 @@
|
||||
import cheerio from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { FilterInputs } from "@libs/filterInputs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
const pluginId = "novelupdates";
|
||||
const baseUrl = "https://www.novelupdates.com/";
|
||||
|
||||
const headers = {
|
||||
"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",
|
||||
};
|
||||
|
||||
function getPopularNovelsUrl(
|
||||
page: number,
|
||||
{ showLatestNovels, filters }: Plugin.Options
|
||||
) {
|
||||
let url = `${baseUrl}${
|
||||
filters
|
||||
? "series-finder"
|
||||
: showLatestNovels
|
||||
? "latest-series"
|
||||
: "series-ranking"
|
||||
}/`;
|
||||
|
||||
if (!filters) {
|
||||
url += "?rank=week";
|
||||
} else {
|
||||
url += "?sf=1";
|
||||
}
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.novelType) && filters.novelType?.length) {
|
||||
url += "&nt=" + filters?.novelType.join(",");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.genres) && filters.genres?.length) {
|
||||
url += "&gi=" + filters?.genres.join(",") + "&mgi=and";
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.language) && filters.language?.length) {
|
||||
url += "&org=" + filters?.language.join(",");
|
||||
}
|
||||
|
||||
if (filters.storyStatus) {
|
||||
url += "&ss=" + filters?.storyStatus;
|
||||
}
|
||||
}
|
||||
|
||||
if (!filters?.sort) {
|
||||
url += "&sort=" + "sdate";
|
||||
} else {
|
||||
url += "&sort=" + filters?.sort;
|
||||
}
|
||||
|
||||
if (!filters?.order) {
|
||||
url += "&order=" + "desc";
|
||||
} else {
|
||||
url += "&order=" + filters?.order;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ showLatestNovels, filters }
|
||||
) {
|
||||
const url = getPopularNovelsUrl(page, { showLatestNovels, filters });
|
||||
|
||||
const result = await fetchApi(url, { headers: headers }, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.search_main_box_nu").each(function (res) {
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelName = loadedCheerio(this).find(".search_title > a").text();
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".search_title > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, { headers: headers }, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".seriestitlenu").text();
|
||||
|
||||
novel.cover = loadedCheerio(".seriesimg > img").attr("src");
|
||||
|
||||
novel.author = loadedCheerio("#showauthors").text().trim();
|
||||
|
||||
novel.genres = loadedCheerio("#seriesgenre")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
novel.status = loadedCheerio("#editstatus").text().includes("Ongoing")
|
||||
? "Ongoing"
|
||||
: "Completed";
|
||||
|
||||
let type = loadedCheerio("#showtype").text().trim();
|
||||
|
||||
let summary = loadedCheerio("#editdescription").text().trim();
|
||||
|
||||
novel.summary = summary + `\n\nType: ${type}`;
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
const novelId = loadedCheerio("input#mypostid").attr("value")!;
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("action", "nd_getchapters");
|
||||
formData.append("mygrr", "0");
|
||||
formData.append("mypostid", novelId);
|
||||
|
||||
let link = "https://www.novelupdates.com/wp-admin/admin-ajax.php";
|
||||
|
||||
const text = await fetchApi(
|
||||
link,
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
headers: headers,
|
||||
},
|
||||
pluginId
|
||||
).then((data) => data.text());
|
||||
|
||||
loadedCheerio = cheerio.load(text);
|
||||
|
||||
loadedCheerio("li.sp_li_chp").each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
|
||||
const releaseDate = null;
|
||||
|
||||
const chapterUrl =
|
||||
"https:" +
|
||||
loadedCheerio(this).find("a").first().next().attr("href");
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
function getLocation(href: string) {
|
||||
var match = href.match(
|
||||
/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
||||
);
|
||||
return match && `${match[1]}//${match[3]}`;
|
||||
}
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
// console.log('Original URL: ', chapterUrl);
|
||||
|
||||
let chapterText = "";
|
||||
|
||||
const result = await fetchApi(
|
||||
chapterUrl,
|
||||
{
|
||||
method: "GET",
|
||||
headers: headers,
|
||||
},
|
||||
pluginId
|
||||
);
|
||||
const body = await result.text();
|
||||
|
||||
// console.log(result.chapterUrl);
|
||||
|
||||
// console.log('Redirected URL: ', result.chapterUrl);
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let isWuxiaWorld = result.chapterUrl.toLowerCase().includes("wuxiaworld");
|
||||
|
||||
let isBlogspot = result.chapterUrl.toLowerCase().includes("blogspot");
|
||||
|
||||
let isTumblr = result.chapterUrl.toLowerCase().includes("tumblr");
|
||||
|
||||
let isWattpad = result.chapterUrl.toLowerCase().includes("wattpad");
|
||||
|
||||
let isLightNovelsTls = result.chapterUrl
|
||||
.toLowerCase()
|
||||
.includes("lightnovelstranslations");
|
||||
|
||||
let isiNovelTranslation = result.chapterUrl
|
||||
.toLowerCase()
|
||||
.includes("inoveltranslation");
|
||||
|
||||
let isTravisTranslation = result.chapterUrl
|
||||
.toLowerCase()
|
||||
.includes("travistranslations");
|
||||
|
||||
/**
|
||||
* Checks if its a wordpress site
|
||||
*/
|
||||
let isWordPressStr =
|
||||
loadedCheerio('meta[name="generator"]').attr("content") ||
|
||||
loadedCheerio("footer").text();
|
||||
|
||||
let isWordPress = false;
|
||||
|
||||
if (isWordPressStr) {
|
||||
isWordPress =
|
||||
isWordPressStr.toLowerCase().includes("wordpress") ||
|
||||
isWordPressStr.includes("Site Kit by Google") ||
|
||||
loadedCheerio(".powered-by")
|
||||
.text()
|
||||
.toLowerCase()
|
||||
.includes("wordpress");
|
||||
}
|
||||
|
||||
let isRainOfSnow = result.chapterUrl.toLowerCase().includes("rainofsnow");
|
||||
|
||||
let isWebNovel = result.chapterUrl.toLowerCase().includes("webnovel");
|
||||
|
||||
let isHostedNovel = result.chapterUrl.toLowerCase().includes("hostednovel");
|
||||
|
||||
let isScribbleHub = result.chapterUrl.toLowerCase().includes("scribblehub");
|
||||
|
||||
if (isWuxiaWorld) {
|
||||
chapterText = loadedCheerio("#chapter-content").html()!;
|
||||
} else if (isRainOfSnow) {
|
||||
chapterText = loadedCheerio("div.content").html()!;
|
||||
} else if (isTumblr) {
|
||||
chapterText = loadedCheerio(".post").html()!;
|
||||
} else if (isBlogspot) {
|
||||
loadedCheerio(".post-share-buttons").remove();
|
||||
chapterText = loadedCheerio(".entry-content").html()!;
|
||||
} else if (isHostedNovel) {
|
||||
chapterText = loadedCheerio(".chapter").html()!;
|
||||
} else if (isScribbleHub) {
|
||||
chapterText = loadedCheerio("div.chp_raw").html()!;
|
||||
} else if (isWattpad) {
|
||||
chapterText = loadedCheerio(".container pre").html()!;
|
||||
} else if (isTravisTranslation) {
|
||||
chapterText = loadedCheerio(".reader-content").html()!;
|
||||
} else if (isLightNovelsTls) {
|
||||
chapterText = loadedCheerio(".text_story").html()!;
|
||||
} else if (isiNovelTranslation) {
|
||||
chapterText = loadedCheerio(".chakra-skeleton").html()!;
|
||||
} else if (isWordPress) {
|
||||
/**
|
||||
* Remove wordpress bloat tags
|
||||
*/
|
||||
|
||||
const bloatClasses = [
|
||||
".c-ads",
|
||||
"#madara-comments",
|
||||
"#comments",
|
||||
".content-comments",
|
||||
".sharedaddy",
|
||||
".wp-dark-mode-switcher",
|
||||
".wp-next-post-navi",
|
||||
".wp-block-buttons",
|
||||
".wp-block-columns",
|
||||
".post-cats",
|
||||
".sidebar",
|
||||
".author-avatar",
|
||||
".ezoic-ad",
|
||||
];
|
||||
|
||||
bloatClasses.map((tag) => loadedCheerio(tag).remove());
|
||||
|
||||
chapterText =
|
||||
loadedCheerio(".entry-content").html() ||
|
||||
loadedCheerio(".single_post").html() ||
|
||||
loadedCheerio(".post-entry").html() ||
|
||||
loadedCheerio(".main-content").html() ||
|
||||
loadedCheerio("article.post").html() ||
|
||||
loadedCheerio(".content").html() ||
|
||||
loadedCheerio("#content").html() ||
|
||||
loadedCheerio(".page-body").html() ||
|
||||
loadedCheerio(".td-page-content").html()!;
|
||||
} else if (isWebNovel) {
|
||||
chapterText = loadedCheerio(".cha-words").html()!;
|
||||
|
||||
if (!chapterText) {
|
||||
chapterText = loadedCheerio("._content").html()!;
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Remove unnecessary tags
|
||||
*/
|
||||
const tags = ["nav", "header", "footer", ".hidden"];
|
||||
|
||||
tags.map((tag) => loadedCheerio(tag).remove());
|
||||
|
||||
chapterText = loadedCheerio("body").html()!;
|
||||
}
|
||||
|
||||
if (chapterText) {
|
||||
/**
|
||||
* Convert relative urls to absolute
|
||||
*/
|
||||
chapterText = chapterText.replace(
|
||||
/href="\//g,
|
||||
`href="${getLocation(result.chapterUrl)}/`
|
||||
);
|
||||
}
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url =
|
||||
"https://www.novelupdates.com/?s=" +
|
||||
searchTerm +
|
||||
"&post_type=seriesplans";
|
||||
|
||||
const result = await fetchApi(url, { headers: headers }, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.search_main_box_nu").each(function () {
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelName = loadedCheerio(this).find(".search_title > a").text();
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".search_title > a")
|
||||
.attr("href")
|
||||
?.split("/")[4];
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
const filters = [
|
||||
{
|
||||
key: "sort",
|
||||
label: "Sort Results By",
|
||||
values: [
|
||||
{ label: "Last Updated", value: "sdate" },
|
||||
{ label: "Rating", value: "srate" },
|
||||
{ label: "Rank", value: "srank" },
|
||||
{ label: "Reviews", value: "sreview" },
|
||||
{ label: "Chapters", value: "srel" },
|
||||
{ label: "Title", value: "abc" },
|
||||
{ label: "Readers", value: "sread" },
|
||||
{ label: "Frequency", value: "sfrel" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "order",
|
||||
label: "Order",
|
||||
values: [
|
||||
{ label: "Descending", value: "desc" },
|
||||
{ label: "Ascending", value: "asc" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "storyStatus",
|
||||
label: "Story Status (Translation)",
|
||||
values: [
|
||||
{ label: "All", value: "" },
|
||||
{ label: "Completed", value: "2" },
|
||||
{ label: "Ongoing", value: "3" },
|
||||
{ label: "Hiatus", value: "4" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "language",
|
||||
label: "Language",
|
||||
values: [
|
||||
{ label: "Chinese", value: 495 },
|
||||
{ label: "Filipino", value: 9181 },
|
||||
{ label: "Indonesian", value: 9179 },
|
||||
{ label: "Japanese", value: 496 },
|
||||
{ label: "Khmer", value: 18657 },
|
||||
{ label: "Korean", value: 497 },
|
||||
{ label: "Malaysian", value: 9183 },
|
||||
{ label: "Thai", value: 9954 },
|
||||
{ label: "Vietnamese", value: 9177 },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "novelType",
|
||||
label: "Novel Type",
|
||||
values: [
|
||||
{ label: "Light Novel", value: "2443" },
|
||||
{ label: "Published Novel", value: "26874" },
|
||||
{ label: "Web Novel", value: "2444" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
label: "Genres",
|
||||
values: [
|
||||
{ label: "Action", value: 8 },
|
||||
{ label: "Adult", value: 280 },
|
||||
{ label: "Adventure", value: 13 },
|
||||
{ label: "Comedy", value: 17 },
|
||||
{ label: "Drama", value: 9 },
|
||||
{ label: "Ecchi", value: 292 },
|
||||
{ label: "Fantasy", value: 5 },
|
||||
{ label: "Gender Bender", value: 168 },
|
||||
{ label: "Harem", value: 3 },
|
||||
{ label: "Historical", value: 330 },
|
||||
{ label: "Horror", value: 343 },
|
||||
{ label: "Josei", value: 324 },
|
||||
{ label: "Martial Arts", value: 14 },
|
||||
{ label: "Mature", value: 4 },
|
||||
{ label: "Mecha", value: 10 },
|
||||
{ label: "Mystery", value: 245 },
|
||||
{ label: "Psychoical", value: 486 },
|
||||
{ label: "Romance", value: 15 },
|
||||
{ label: "School Life", value: 6 },
|
||||
{ label: "Sci-fi", value: 11 },
|
||||
{ label: "Seinen", value: 18 },
|
||||
{ label: "Shoujo", value: 157 },
|
||||
{ label: "Shoujo Ai", value: 851 },
|
||||
{ label: "Shounen", value: 12 },
|
||||
{ label: "Shounen Ai", value: 1692 },
|
||||
{ label: "Slice of Life", value: 7 },
|
||||
{ label: "Smut", value: 281 },
|
||||
{ label: "Sports", value: 1357 },
|
||||
{ label: "Supernatural", value: 16 },
|
||||
{ label: "Tragedy", value: 132 },
|
||||
{ label: "Wuxia", value: 479 },
|
||||
{ label: "Xianxia", value: 480 },
|
||||
{ label: "Xuanhuan", value: 3954 },
|
||||
{ label: "Yaoi", value: 560 },
|
||||
{ label: "Yuri", value: 922 },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: "Novel Updates",
|
||||
version: "0.5.0",
|
||||
icon: "src/en/novelupdates/icon.png",
|
||||
site: baseUrl,
|
||||
protected: false,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
filters,
|
||||
};
|
||||
@@ -0,0 +1,274 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { FilterInputs } from "@libs/filterInputs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "PandaMTL";
|
||||
export const name = "PandaMTL";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/en/wordpress/icon.png";
|
||||
export const site = "https://www.pandamtl.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters }
|
||||
) {
|
||||
let link = `${baseUrl}series/?page=${page}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length) {
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
}
|
||||
|
||||
link += "&status=" + (filters?.status ? filters?.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters?.order : "popular");
|
||||
|
||||
const body = await fetchApi(link, {}, pluginId).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1.entry-title").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
|
||||
loadedCheerio("div.serl:nth-child(3) > span").each(function () {
|
||||
const detailName = loadedCheerio(this).text().trim();
|
||||
const detail = loadedCheerio(this).next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "الكاتب":
|
||||
case "Author":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio("div.sertostat > span").attr("class");
|
||||
|
||||
novel.genres = loadedCheerio(".sertogenre")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
novel.summary = loadedCheerio(".sersys")
|
||||
.find("br")
|
||||
.replaceWith("\n")
|
||||
.end()
|
||||
.text();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".eplister")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const chapterName =
|
||||
loadedCheerio(this).find(".epl-num").text() +
|
||||
" - " +
|
||||
loadedCheerio(this).find(".epl-title").text();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find(".epl-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio(".epcontent").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.maindet").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
export const filters = [
|
||||
{
|
||||
key: "order",
|
||||
label: "Sort By",
|
||||
values: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
|
||||
{ label: "Latest Update", value: "update" },
|
||||
|
||||
{ label: "Latest Added", value: "latest" },
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
label: "Status",
|
||||
values: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
|
||||
{ label: "Hiatus", value: "hiatus" },
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
label: "Type",
|
||||
values: [
|
||||
{ label: "Light Novel (KR)", value: "light-novel-kr" },
|
||||
|
||||
{ label: "Web Novel", value: "web-novel" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
label: "Genres",
|
||||
values: [
|
||||
{ label: "Action", value: "action" },
|
||||
|
||||
{ label: "Adult", value: "adult" },
|
||||
|
||||
{ label: "Adventure", value: "adventure" },
|
||||
|
||||
{ label: "Comedy", value: "comedy" },
|
||||
|
||||
{ label: "Ecchi", value: "ecchi" },
|
||||
|
||||
{ label: "Fantasy", value: "fantasy" },
|
||||
|
||||
{ label: "Harem", value: "harem" },
|
||||
|
||||
{ label: "Josei", value: "josei" },
|
||||
|
||||
{ label: "Martial Arts", value: "martial-arts" },
|
||||
|
||||
{ label: "Mature", value: "mature" },
|
||||
|
||||
{ label: "Romance", value: "romance" },
|
||||
|
||||
{ label: "School Life", value: "school-life" },
|
||||
|
||||
{ label: "Sci-fi", value: "sci-fi" },
|
||||
|
||||
{ label: "Seinen", value: "seinen" },
|
||||
|
||||
{ label: "Slice of Life", value: "slice-of-life" },
|
||||
|
||||
{ label: "Smut", value: "smut" },
|
||||
|
||||
{ label: "Sports", value: "sports" },
|
||||
|
||||
{ label: "Supernatural", value: "supernatural" },
|
||||
|
||||
{ label: "Tragedy", value: "tragedy" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,146 @@
|
||||
import cheerio from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "wuxiaworld";
|
||||
export const name = "Wuxia World (WIP)";
|
||||
export const version = "0.5.0";
|
||||
export const icon = "src/en/wuxiaworld/icon.png";
|
||||
export const site = "https://www.wuxiaworld.com/";
|
||||
exports.protected = true;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const link = `${baseUrl}api/novels`;
|
||||
|
||||
const result = await fetchApi(link, {}, pluginId);
|
||||
const data = await result.json();
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
data.items.map((novel) => {
|
||||
let name = novel.name;
|
||||
let cover = novel.coverUrl;
|
||||
let url = baseUrl + "novel/" + novel.slug + "/";
|
||||
|
||||
novels.push({
|
||||
name,
|
||||
cover,
|
||||
url,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
console.log(url);
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio("h1.line-clamp-2").text();
|
||||
|
||||
novel.cover = loadedCheerio("img.absolute").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(
|
||||
"div.flex-col:nth-child(4) > div > div > span > span"
|
||||
)
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
novel.author = loadedCheerio("div.MuiGrid-container > div > div > div")
|
||||
.filter(function () {
|
||||
return loadedCheerio(this).text().trim() === "Author:";
|
||||
})
|
||||
.next()
|
||||
.text();
|
||||
|
||||
let genres: string[] = [];
|
||||
|
||||
loadedCheerio("a.MuiLink-underlineNone").each(function () {
|
||||
genres.push(loadedCheerio(this).find("div > div").text());
|
||||
});
|
||||
|
||||
novel.genres = genres.join(",");
|
||||
|
||||
novel.status = loadedCheerio("div.font-set-b10")
|
||||
.text()
|
||||
.includes("Complete");
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio("div.border-b").each(function () {
|
||||
const name = loadedCheerio(this)
|
||||
.find("a > div > div > div > span")
|
||||
.text();
|
||||
const releaseTime = loadedCheerio(this)
|
||||
.find("a > div > div > div > div > span")
|
||||
.text();
|
||||
let url = loadedCheerio(this).find("a").attr("href")?.slice(1);
|
||||
url = `${baseUrl}${url}`;
|
||||
|
||||
chapter.push({ name, releaseTime, url });
|
||||
});
|
||||
|
||||
novel.chapters = chapter;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
loadedCheerio(".chapter-nav").remove();
|
||||
|
||||
loadedCheerio("#chapter-content > script").remove();
|
||||
|
||||
let chapterText = loadedCheerio("#chapter-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const searchUrl = "https://www.wuxiaworld.com/api/novels/search?query=";
|
||||
|
||||
const url = `${searchUrl}${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const data = await result.json();
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
data.items.map((novel) => {
|
||||
let name = novel.name;
|
||||
let cover = novel.cover;
|
||||
let url = baseUrl + "novel/" + novel.slug + "/";
|
||||
|
||||
novels.push({
|
||||
name,
|
||||
url,
|
||||
cover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
@@ -1,126 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = 'chireads.com';
|
||||
const sourceName = 'Chireads';
|
||||
|
||||
const baseUrl = 'https://chireads.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}category/translatedtales/page/${page}/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('#content li').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.news-list-tit h5').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.news-list-tit h5 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: '',
|
||||
artist: '',
|
||||
status: '',
|
||||
genres: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.inform-title').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('.inform-product img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('.inform-inform-txt').text().trim();
|
||||
|
||||
let chapters = [];
|
||||
|
||||
loadedCheerio('.chapitre-table a').each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).attr('href');
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters;
|
||||
|
||||
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('#content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}search?x=0&y=0&name=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('#content li').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.news-list-tit h5').text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.news-list-tit h5 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',
|
||||
icon: 'src/fr/chireads/icon.png',
|
||||
lang: languages.French,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "chireads.com";
|
||||
export const name = "Chireads";
|
||||
export const site = "https://chireads.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/fr/chireads/icon.png";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}category/translatedtales/page/${page}/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#content li").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".news-list-tit h5").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".news-list-tit h5 a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: "",
|
||||
genres: "",
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".inform-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".inform-product img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(".inform-inform-txt").text().trim();
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".chapitre-table a").each(function () {
|
||||
const chapterName = loadedCheerio(this).text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio("#content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}search?x=0&y=0&name=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("#content li").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".news-list-tit h5").text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".news-list-tit h5 a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -0,0 +1,140 @@
|
||||
import cheerio from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "NDG.com";
|
||||
export const name = "NovelDeGlace";
|
||||
export const site = "https://noveldeglace.com/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/fr/noveldeglace/icon.png";
|
||||
|
||||
const pluginId = id;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
let url = baseUrl + "roman";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text().trim();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel: Novel.instance = { url };
|
||||
|
||||
novel.name = loadedCheerio(
|
||||
"div.entry-content > div > strong"
|
||||
)[0].nextSibling?.nodeType.trim();
|
||||
|
||||
novel.cover = loadedCheerio(".su-row > div > div > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio("div[data-title=Synopsis]").text();
|
||||
|
||||
const author = loadedCheerio(
|
||||
"div.romans > div.project-large > div.su-row > div.su-column.su-column-size-3-4 > div > div:nth-child(3) > strong"
|
||||
)[0];
|
||||
|
||||
novel.author = author ? author.nextSibling.nodeValue.trim() : null;
|
||||
|
||||
novel.genres = loadedCheerio(".genre")
|
||||
.text()
|
||||
.replace("Genre : ", "")
|
||||
.replace(/, /g, ",");
|
||||
|
||||
let novelChapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".chpt").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
novelChapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = novelChapters;
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterText = loadedCheerio(".chapter-content").html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
let url = baseUrl + "roman";
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article").each(function () {
|
||||
const novelName = loadedCheerio(this).find("h2").text().trim();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
novels = novels.filter((novel) =>
|
||||
novel.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
@@ -1,147 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const sourceName = 'NovelDeGlace';
|
||||
const pluginId = 'NDG.com';
|
||||
|
||||
const baseUrl = 'https://noveldeglace.com/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
let url = baseUrl + 'roman';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('article').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h2').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('h2 > 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, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {url};
|
||||
|
||||
novel.name = loadedCheerio(
|
||||
'div.entry-content > div > strong',
|
||||
)[0].nextSibling.nodeValue.trim();
|
||||
|
||||
novel.cover = loadedCheerio('.su-row > div > div > img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('div[data-title=Synopsis]').text();
|
||||
|
||||
const author = loadedCheerio(
|
||||
'div.romans > div.project-large > div.su-row > div.su-column.su-column-size-3-4 > div > div:nth-child(3) > strong',
|
||||
)[0];
|
||||
|
||||
novel.author = author ? author.nextSibling.nodeValue.trim() : null;
|
||||
|
||||
novel.genres = loadedCheerio('.genre')
|
||||
.text()
|
||||
.replace('Genre : ', '')
|
||||
.replace(/, /g, ',');
|
||||
|
||||
let novelChapters = [];
|
||||
|
||||
loadedCheerio('.chpt').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
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, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let chapterText = loadedCheerio('.chapter-content').html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
let url = baseUrl + 'roman';
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('article').each(function () {
|
||||
const novelName = loadedCheerio(this).find('h2').text().trim();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('h2 > 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',
|
||||
icon: 'src/fr/noveldeglace/icon.png',
|
||||
lang: languages.French,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "meionovel";
|
||||
export const name = "MeioNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/meionovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://meionovel.id/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "morenovel";
|
||||
export const name = "MoreNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/morenovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://morenovel.net/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (true) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,205 @@
|
||||
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchFile, fetchApi } from "@libs/fetch";
|
||||
import { Novel, Plugin, Chapter } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
import { NovelStatus } from "@libs/novelStatus"
|
||||
import { parseMadaraDate } from "@libs/parseMadaraDate";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const id = "wbnovel";
|
||||
export const name = "WBNovel [madara]";
|
||||
export const icon = "multisrc/madara/icons/wbnovel.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https://wbnovel.com/";
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async (pageNo, {showLatestNovels}) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const sortOrder = showLatestNovels
|
||||
? '?m_orderby=latest'
|
||||
: '/?m_orderby=rating';
|
||||
|
||||
let url = site + "novel" + '/page/' + pageNo + sortOrder;
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
loadedCheerio('.page-item-detail').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this).find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel: Novel.Item = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters = async (
|
||||
novelUrl
|
||||
) => {
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
const body = await fetchApi(novelUrl).then(res => res.text());
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.manga-title-badges').remove();
|
||||
|
||||
novel.name = loadedCheerio('.post-title h1').text().trim();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
|
||||
loadedCheerio('.summary_image > a > img').attr('src') ||
|
||||
defaultCover;
|
||||
|
||||
loadedCheerio('.post-content_item, .post-content').each(function () {
|
||||
const detailName = loadedCheerio(this).find('h5').text().trim();
|
||||
const detail = loadedCheerio(this).find('.summary-content').text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Genre(s)':
|
||||
case 'التصنيفات':
|
||||
novel.genres = detail.replace(/[\t\n]/g, ',');
|
||||
break;
|
||||
case 'Author(s)':
|
||||
case 'المؤلف':
|
||||
case 'المؤلف (ين)':
|
||||
novel.author = detail;
|
||||
break;
|
||||
case 'Status':
|
||||
case 'الحالة':
|
||||
novel.status =
|
||||
detail.includes('OnGoing') || detail.includes('مستمرة')
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
loadedCheerio('div.summary__content .code-block,script').remove();
|
||||
novel.summary = loadedCheerio('div.summary__content').text().trim();
|
||||
|
||||
|
||||
let html;
|
||||
|
||||
if (false) {
|
||||
const novelId =
|
||||
loadedCheerio('.rating-post-id').attr('value') ||
|
||||
loadedCheerio('#manga-chapters-holder').attr('data-id') || '';
|
||||
|
||||
const body = {
|
||||
action: "manga_get_chapters",
|
||||
manga: novelId,
|
||||
}
|
||||
html = await fetchApi(
|
||||
baseUrl + 'wp-admin/admin-ajax.php',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(res => res.text());
|
||||
} else {
|
||||
html = await fetchApi(
|
||||
baseUrl + 'ajax/chapters/',
|
||||
{ method: 'POST' })
|
||||
.then(res => res.text());
|
||||
}
|
||||
|
||||
if (html !== '0') {
|
||||
loadedCheerio = parseHTML(html);
|
||||
}
|
||||
|
||||
const chapters: Chapter.Item[] = [];
|
||||
loadedCheerio('.wp-manga-chapter').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
|
||||
let releaseDate = null;
|
||||
releaseDate = loadedCheerio(this)
|
||||
.find('span.chapter-release-date')
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
if (releaseDate) {
|
||||
releaseDate = parseMadaraDate(releaseDate);
|
||||
} else {
|
||||
/**
|
||||
* Insert current date
|
||||
*/
|
||||
|
||||
releaseDate = dayjs().format('LL');
|
||||
}
|
||||
|
||||
let chapterUrl = loadedCheerio(this).find('a').attr('href') || '';
|
||||
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async (chapterUrl) => {
|
||||
const url = baseUrl + "/" + "novel" + "/" + chapterUrl;
|
||||
|
||||
const body = await fetchApi(chapterUrl).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
const chapterText =
|
||||
loadedCheerio('.text-left').html() ||
|
||||
loadedCheerio('.text-right').html() ||
|
||||
loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async (searchTerm) => {
|
||||
const novels: Novel.Item[] = [];
|
||||
const url = baseUrl + "?s=" + searchTerm + "&post_type=wp-manga";
|
||||
|
||||
const body = await fetchApi(url).then(res => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
|
||||
loadedCheerio('.c-tabs-item__content').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.post-title').text().trim();
|
||||
|
||||
let image = loadedCheerio(this).find('img');
|
||||
const novelCover = image.attr('data-src') || image.attr('src');
|
||||
|
||||
let novelUrl = loadedCheerio(this)
|
||||
.find('.post-title')
|
||||
.find('a')
|
||||
.attr('href') || '';
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async (url) => {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -1,142 +0,0 @@
|
||||
const cheerio = require('cheerio')
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = "IDWN.id";
|
||||
const sourceName = 'IndoWebNovel';
|
||||
|
||||
const baseUrl = 'https://indowebnovel.id/id/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.novellist-blc li').each(function () {
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = null;
|
||||
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();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
url,
|
||||
name: '',
|
||||
cover: '',
|
||||
author: '',
|
||||
status: '',
|
||||
genres: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.series-title').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('.series-thumb > img').attr('src');
|
||||
|
||||
novel.summary = loadedCheerio('.series-synops').text().trim();
|
||||
|
||||
novel.status = loadedCheerio('.status').text().trim();
|
||||
|
||||
novel.genres = [];
|
||||
|
||||
loadedCheerio('.series-genres').each(function () {
|
||||
novel.genres.push(loadedCheerio(this).find('a').text().trim());
|
||||
});
|
||||
|
||||
novel.genres = novel.genres.toString();
|
||||
|
||||
let chapters = [];
|
||||
|
||||
loadedCheerio('.series-chapterlist li').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text().trim();
|
||||
const releaseDate = null;
|
||||
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);
|
||||
|
||||
const chapterText = loadedCheerio('.reader').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.novellist-blc li').each(function () {
|
||||
const novelName = loadedCheerio(this).find('a').text();
|
||||
const novelCover = null;
|
||||
const novelUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
if (novelName.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
icon: 'src/id/indowebnovel/icon.png',
|
||||
version: '1.0.0',
|
||||
lang: languages.Indonesian,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,143 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export const id = "IDWN.id";
|
||||
export const name = "IndoWebNovel";
|
||||
export const site = "https://indowebnovel.id/id/";
|
||||
export const icon = "src/id/indowebnovel/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl || !novelName) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
author: "",
|
||||
status: "",
|
||||
genres: "",
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb > img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
const genres: string[] = [];
|
||||
|
||||
loadedCheerio(".series-genres").each(function () {
|
||||
genres.push(loadedCheerio(this).find("a").text().trim());
|
||||
});
|
||||
|
||||
novel.genres = genres.join(",");
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text().trim();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".reader").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}daftar-novel/`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".novellist-blc li").each(function () {
|
||||
const novelName = loadedCheerio(this).find("a").text();
|
||||
const novelCover = defaultCover;
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
if (novelName.toLowerCase().includes(searchTerm.toLowerCase())) {
|
||||
novels.push(novel);
|
||||
}
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -1,162 +0,0 @@
|
||||
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 = "novelringan.com";
|
||||
|
||||
const sourceName = 'NovelRingan';
|
||||
|
||||
const baseUrl = 'https://novelringan.com/';
|
||||
const coverUriPrefix = 'https://i0.wp.com/novelringan.com/wp-content/uploads/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}/top-novel/page/${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const novels = [];
|
||||
|
||||
loadedCheerio('article.post').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.entry-title').text()?.trim();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find('img').attr('data-sxrx');
|
||||
const novelUrl = loadedCheerio(this).find('h2 > 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,
|
||||
name: '',
|
||||
cover: '',
|
||||
genres: '',
|
||||
author: '',
|
||||
status: Status.Unknown,
|
||||
artist: '',
|
||||
summary: '',
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.entry-title').text()?.trim();
|
||||
novel.cover =
|
||||
coverUriPrefix + loadedCheerio('img.ts-post-image').attr('data-sxrx');
|
||||
novel.summary = loadedCheerio(
|
||||
'body > div.site-container > div > main > article > div > div.maininfo > span > p',
|
||||
).text();
|
||||
|
||||
let genreSelector = loadedCheerio(
|
||||
'body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(4)',
|
||||
).text();
|
||||
|
||||
novel.genres = genreSelector.includes('Genre')
|
||||
? genreSelector.replace('Genre:', '').trim()
|
||||
: '';
|
||||
|
||||
let statusSelector = loadedCheerio(
|
||||
'body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(3)',
|
||||
).text();
|
||||
|
||||
novel.status = statusSelector.includes('Status')
|
||||
? statusSelector.replace('Status:', '').trim()
|
||||
: Status.Unknown;
|
||||
|
||||
let chapters = [];
|
||||
|
||||
loadedCheerio('.bxcl > ul > li').each(function () {
|
||||
const chapterName = loadedCheerio(this).find('a').text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find('a').attr('href');
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
chapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = chapters.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);
|
||||
|
||||
loadedCheerio('.entry-content div[style="display:none"]').remove();
|
||||
|
||||
const chapterText = loadedCheerio('.entry-content').html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = baseUrl + '?s=' + searchTerm;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('article.post').each(function () {
|
||||
const novelName = loadedCheerio(this).find('.entry-title').text();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find('img').attr('data-sxrx');
|
||||
|
||||
const novelUrl = loadedCheerio(this).find('h2 > a').attr('href');
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
icon: 'src/id/novelringan/icon.png',
|
||||
version: '1.0.0',
|
||||
lang: languages.Indonesian,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "novelringan.com";
|
||||
export const name = "NovelRingan";
|
||||
export const site = "https://novelringan.com/";
|
||||
export const icon = "src/id/novelringan/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const baseUrl = site;
|
||||
const coverUriPrefix = "https://i0.wp.com/novelringan.com/wp-content/uploads/";
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}/top-novel/page/${page}`;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.post").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".entry-title")
|
||||
.text()
|
||||
?.trim();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find("img").attr("data-sxrx");
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
url,
|
||||
name: "",
|
||||
cover: "",
|
||||
genres: "",
|
||||
author: "",
|
||||
status: NovelStatus.Unknown,
|
||||
summary: "",
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".entry-title").text()?.trim();
|
||||
novel.cover =
|
||||
coverUriPrefix +
|
||||
loadedCheerio("img.ts-post-image").attr("data-sxrx");
|
||||
novel.summary = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > p"
|
||||
).text();
|
||||
|
||||
let genreSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(4)"
|
||||
).text();
|
||||
|
||||
novel.genres = genreSelector.includes("Genre")
|
||||
? genreSelector.replace("Genre:", "").trim()
|
||||
: "";
|
||||
|
||||
let statusSelector = loadedCheerio(
|
||||
"body > div.site-container > div > main > article > div > div.maininfo > span > ul > li:nth-child(3)"
|
||||
).text();
|
||||
|
||||
novel.status = statusSelector.includes("Status")
|
||||
? statusSelector.replace("Status:", "").trim()
|
||||
: NovelStatus.Unknown;
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".bxcl > ul > li").each(function () {
|
||||
const chapterName = loadedCheerio(this).find("a").text();
|
||||
const releaseDate = null;
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
const chapter = {
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
};
|
||||
|
||||
chapters.push(chapter);
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const url = chapterUrl;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('.entry-content div[style="display:none"]').remove();
|
||||
|
||||
const chapterText = loadedCheerio(".entry-content").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = baseUrl + "?s=" + searchTerm;
|
||||
|
||||
const result = await fetchApi(url);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.post").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".entry-title").text();
|
||||
const novelCover =
|
||||
coverUriPrefix + loadedCheerio(this).find("img").attr("data-sxrx");
|
||||
|
||||
const novelUrl = loadedCheerio(this).find("h2 > a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -1,151 +0,0 @@
|
||||
const cheerio = require('cheerio')
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = "sakura.id";
|
||||
const sourceName = 'SakuraNovel';
|
||||
|
||||
const baseUrl = 'https://sakuranovel.id/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const url = `${baseUrl}advanced-search/page/${page}/?title&author&yearx&status&type&order=rating&country%5B0%5D=china&country%5B1%5D=jepang&country%5B2%5D=unknown`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.flexbox2-item').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.flexbox2-title span')
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.flexbox2-content > a')
|
||||
.attr('href');
|
||||
|
||||
const novel = {name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const result = await fetchApi(novelUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novel = {
|
||||
name: sourceName,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio('.series-title h2').text().trim();
|
||||
|
||||
novel.cover = loadedCheerio('.series-thumb img').attr('src');
|
||||
|
||||
loadedCheerio('.series-infolist > li').each(function () {
|
||||
const detailName = loadedCheerio(this).find('b').text().trim();
|
||||
const detail = loadedCheerio(this).find('b').next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case 'Author':
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio('.status').text().trim();
|
||||
|
||||
novel.genres = loadedCheerio('.series-genres')
|
||||
.prop('innerHTML')
|
||||
.replace(/<.*?>(.*?)<.*?>/g, '$1,')
|
||||
.slice(0, -1);
|
||||
|
||||
novel.summary = loadedCheerio('.series-synops').text().trim();
|
||||
|
||||
let chapters = [];
|
||||
|
||||
loadedCheerio('.series-chapterlist li').each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find('a span')
|
||||
.first()
|
||||
.text()
|
||||
.replace(`${novel.novelName} – `, '')
|
||||
.replace('Bahasa Indonesia', '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find('a span')
|
||||
.first()
|
||||
.next()
|
||||
.text();
|
||||
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 result = await fetchApi( chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
const chapterText = loadedCheerio('.reader').html();
|
||||
|
||||
return chapterText
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = cheerio.load(body);
|
||||
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio('.flexbox2-item').each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find('.flexbox2-title span')
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find('img').attr('src');
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find('.flexbox2-content > a')
|
||||
.attr('href');
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
icon: 'src/id/sakuranovel/icon.png',
|
||||
version: '1.0.0',
|
||||
lang: languages.Indonesian,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,156 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "sakura.id";
|
||||
export const name = "SakuraNovel";
|
||||
export const site = "https://sakuranovel.id/";
|
||||
export const icon = "src/id/sakuranovel/icon.png";
|
||||
export const version = "1.0.0";
|
||||
|
||||
const pluginId = id;
|
||||
const sourceName = name;
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const url = `${baseUrl}advanced-search/page/${page}/?title&author&yearx&status&type&order=rating&country%5B0%5D=china&country%5B1%5D=jepang&country%5B2%5D=unknown`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const result = await fetchApi(novelUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novel: Novel.instance = {
|
||||
name: sourceName,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".series-title h2").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".series-thumb img").attr("src");
|
||||
|
||||
loadedCheerio(".series-infolist > li").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this).find("b").next().text().trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "Author":
|
||||
novel.author = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.status = loadedCheerio(".status").text().trim();
|
||||
|
||||
novel.genres = loadedCheerio(".series-genres")
|
||||
.children("a")
|
||||
.map((i, el) => loadedCheerio(el).text())
|
||||
.toArray()
|
||||
.join(",");
|
||||
|
||||
loadedCheerio(".series-synops div").remove();
|
||||
novel.summary = loadedCheerio(".series-synops").text().trim();
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".series-chapterlist li").each(function () {
|
||||
const chapterName = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.text()
|
||||
.replace(/.*?(Chapter.|[0-9])/g, "$1")
|
||||
.replace(/Bahasa Indonesia/g, "")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find("a span")
|
||||
.first()
|
||||
.next()
|
||||
.text();
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const chapterText = loadedCheerio(".readers").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio(".flexbox2-item").each(function () {
|
||||
const novelName = loadedCheerio(this)
|
||||
.find(".flexbox2-title span")
|
||||
.first()
|
||||
.text();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this)
|
||||
.find(".flexbox2-content > a")
|
||||
.attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = { name: novelName, cover: novelCover, url: novelUrl };
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
export const fetchImage: Plugin.fetchImage = fetchFile;
|
||||
@@ -1,205 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const languages = require('@libs/languages');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
// const novelStatus = require('@libs/novelStatus');
|
||||
// const isUrlAbsolute = require('@libs/isAbsoluteUrl');
|
||||
// const parseDate = require('@libs/parseDate');
|
||||
|
||||
const pluginId = 'yomou.syosetu';
|
||||
|
||||
const defaultCoverUri =
|
||||
'https://github.com/LNReader/lnreader-sources/blob/main/icons/src/coverNotAvailable.jpg?raw=true';
|
||||
|
||||
const searchUrl = (pagenum, order) => {
|
||||
return `https://yomou.syosetu.com/search.php?order=${order || 'hyoka'}${!isNaN((pagenum = parseInt(pagenum, 10))) // check if pagenum is a number
|
||||
? `&p=${pagenum <= 1 || pagenum > 100 ? '1' : pagenum}` // check if pagenum is between 1 and 100
|
||||
: '' // if isn't don't set ?p
|
||||
}`;
|
||||
};
|
||||
|
||||
const novelCover = defaultCoverUri;
|
||||
|
||||
async function popularNovels(pageNo) {
|
||||
let novels = [];
|
||||
|
||||
async function getNovelsFromPage(pagenumber) {
|
||||
// load page
|
||||
const result = await fetchApi(searchUrl(pagenumber || null));
|
||||
const body = await result.text();
|
||||
// Cheerio it!
|
||||
const cheerioQuery = cheerio.load(body, { decodeEntities: false });
|
||||
let pageNovels = [];
|
||||
// find class=searchkekka_box
|
||||
cheerioQuery('.searchkekka_box').each(function (i, e) {
|
||||
// get div with link and name
|
||||
const novelDIV = cheerioQuery(this).find('.novel_h');
|
||||
// get link element
|
||||
const novelA = novelDIV.children()[0];
|
||||
// add new novel to array
|
||||
pageNovels.push({
|
||||
name: novelDIV.text(), // get the name
|
||||
url: novelA.attribs.href, // get last part of the link
|
||||
cover: novelCover, // TODO: IDK what to do about covers... On Syo they don't have them
|
||||
});
|
||||
});
|
||||
// return all novels from this page
|
||||
return pageNovels;
|
||||
};
|
||||
|
||||
novels = await getNovelsFromPage(pageNo);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters(novelUrl) {
|
||||
let chapters = [];
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
const cheerioQuery = cheerio.load(body, { decodeEntities: false });
|
||||
|
||||
// create novel object
|
||||
let novel = {
|
||||
url: novelUrl,
|
||||
name: cheerioQuery('.novel_title').text(),
|
||||
author: cheerioQuery('.novel_writername').text().replace('作者:', ''),
|
||||
cover: novelCover,
|
||||
};
|
||||
|
||||
// Get all the chapters
|
||||
const cqGetChapters = cheerioQuery('.novel_sublist2');
|
||||
if (cqGetChapters.length !== 0) {
|
||||
// has more than 1 chapter
|
||||
novel.summary = cheerioQuery('#novel_ex')
|
||||
.text()
|
||||
.replace(/<\s*br.*?>/g, '\n');
|
||||
cqGetChapters.each(function (i, e) {
|
||||
const chapterA = cheerioQuery(this).find('a');
|
||||
const [chapterName, releaseDate, chapterUrl] = [
|
||||
// set the variables
|
||||
chapterA.text(),
|
||||
cheerioQuery(this)
|
||||
.find('dt') // get title
|
||||
.text() // get text
|
||||
.replace(/(.)/g, '') // remove "(edited)" mark
|
||||
.trim(), // trim spaces
|
||||
'https://ncode.syosetu.com' + chapterA.attr('href'),
|
||||
];
|
||||
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
|
||||
});
|
||||
} else {
|
||||
/**
|
||||
* Because there are oneshots on the site, they have to be treated with special care
|
||||
* that's what pisses me off in Shosetsu app. They have this extension,
|
||||
* but every oneshot is set as "there are no chapters" and all contents are thrown into the description!!
|
||||
*/
|
||||
// get summary for oneshot chapter
|
||||
|
||||
const nameResult = await fetchApi(searchUrl() + `&word=${novel.name}`);
|
||||
const nameBody = await nameResult.text();
|
||||
const summaryQuery = cheerio.load(nameBody, { decodeEntities: false });
|
||||
const foundText = summaryQuery('.searchkekka_box')
|
||||
.first()
|
||||
.find('.ex')
|
||||
.text()
|
||||
.replace(/\s{2,}/g, '\n');
|
||||
novel.summary = foundText;
|
||||
|
||||
// add single chapter
|
||||
chapters.push({
|
||||
name: 'Oneshot',
|
||||
releaseTime: cheerioQuery('head')
|
||||
.find("meta[name='WWWC']")
|
||||
.attr('content'), // get date from metadata
|
||||
url: novelUrl, // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot
|
||||
});
|
||||
}
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter(chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
// create cheerioQuery
|
||||
const cheerioQuery = cheerio.load(body, {
|
||||
decodeEntities: false,
|
||||
});
|
||||
|
||||
let chapterText = cheerioQuery('#novel_honbun') // get chapter text
|
||||
.html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
|
||||
async function searchNovels(searchTerm, pageNo) {
|
||||
let novels = [];
|
||||
|
||||
// returns list of novels from given page
|
||||
async function getNovelsFromPage (pagenumber) {
|
||||
// load page
|
||||
const result = await fetchApi(
|
||||
searchUrl(pagenumber || null, null) + `&word=${searchTerm}`
|
||||
);
|
||||
const body = await result.text();
|
||||
// Cheerio it!
|
||||
const cheerioQuery = cheerio.load(body, { decodeEntities: false });
|
||||
|
||||
let pageNovels = [];
|
||||
// find class=searchkekka_box
|
||||
cheerioQuery('.searchkekka_box').each(function (i, e) {
|
||||
// get div with link and name
|
||||
const novelDIV = cheerioQuery(this).find('.novel_h');
|
||||
// get link element
|
||||
const novelA = novelDIV.children()[0];
|
||||
// add new novel to array
|
||||
pageNovels.push({
|
||||
name: novelDIV.text(), // get the name
|
||||
url: novelA.attribs.href, // get last part of the link
|
||||
cover: novelCover, // TODO: IDK what to do about covers... On Syo they don't have them
|
||||
});
|
||||
});
|
||||
// return all novels from this page
|
||||
return pageNovels;
|
||||
};
|
||||
|
||||
// counter of loaded pages
|
||||
// let pagesLoaded = 0;
|
||||
// do {
|
||||
// // always load first one
|
||||
// novels.push(...(await getNovelsFromPage(pagesLoaded + 1)));
|
||||
// pagesLoaded++;
|
||||
// } while (pagesLoaded < maxPageLoad && isNext); // check if we should load more
|
||||
|
||||
novels = await getNovelsFromPage(1);
|
||||
|
||||
/** Use
|
||||
* novels.push(...(await getNovelsFromPage(pageNumber)))
|
||||
* if you want to load more
|
||||
*/
|
||||
|
||||
// respond with novels!
|
||||
return novels;
|
||||
};
|
||||
|
||||
async function fetchImage(url) {
|
||||
|
||||
return await fetchFile(url);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: 'Syosetu',
|
||||
icon: 'src/jp/syosetu/icon.png',
|
||||
version: '1.0.0',
|
||||
site: 'https://yomou.syosetu.com/',
|
||||
lang: languages.Japanese,
|
||||
description: '小説を読もう!は「小説家になろう」に投稿された',
|
||||
protected: false,
|
||||
fetchImage,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
import { load as loadCheerio } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
// const novelStatus = require('@libs/novelStatus');
|
||||
// const isUrlAbsolute = require('@libs/isAbsoluteUrl');
|
||||
// const parseDate = require('@libs/parseDate');
|
||||
|
||||
const pluginId = "yomou.syosetu";
|
||||
|
||||
export const id = pluginId;
|
||||
export const name = "Syosetu";
|
||||
export const icon = "src/jp/syosetu/icon.png";
|
||||
export const version = "1.0.0";
|
||||
export const site = "https//yomou.syosetu.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const searchUrl = (pagenum?: number, order?: string) => {
|
||||
return `https://yomou.syosetu.com/search.php?order=${order || "hyoka"}${
|
||||
pagenum !== undefined
|
||||
? `&p=${pagenum <= 1 || pagenum > 100 ? "1" : pagenum}` // check if pagenum is between 1 and 100
|
||||
: "" // if isn't don't set ?p
|
||||
}`;
|
||||
};
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (pageNo) {
|
||||
async function getNovelsFromPage(pagenumber: number) {
|
||||
// load page
|
||||
const result = await fetchApi(searchUrl(pagenumber));
|
||||
const body = await result.text();
|
||||
// Cheerio it!
|
||||
const cheerioQuery = loadCheerio(body, { decodeEntities: false });
|
||||
let pageNovels: Novel.Item[] = [];
|
||||
// find class=searchkekka_box
|
||||
cheerioQuery(".searchkekka_box").each(function (i, e) {
|
||||
// get div with link and name
|
||||
const novelDIV = cheerioQuery(this).find(".novel_h");
|
||||
// get link element
|
||||
const novelA = novelDIV.children()[0];
|
||||
// add new novel to array
|
||||
pageNovels.push({
|
||||
name: novelDIV.text(), // get the name
|
||||
url: novelA.attribs.href, // get last part of the link
|
||||
cover: defaultCover,
|
||||
});
|
||||
});
|
||||
// return all novels from this page
|
||||
return pageNovels;
|
||||
}
|
||||
const novels = await getNovelsFromPage(pageNo);
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
let chapters: Chapter.Item[] = [];
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
const loadedCheerio = loadCheerio(body, { decodeEntities: false });
|
||||
|
||||
// create novel object
|
||||
let novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
name: loadedCheerio(".novel_title").text(),
|
||||
author: loadedCheerio(".novel_writername")
|
||||
.text()
|
||||
.replace("作者:", ""),
|
||||
cover: defaultCover,
|
||||
};
|
||||
|
||||
// Get all the chapters
|
||||
const cqGetChapters = loadedCheerio(".novel_sublist2");
|
||||
if (cqGetChapters.length !== 0) {
|
||||
// has more than 1 chapter
|
||||
novel.summary = loadedCheerio("#novel_ex")
|
||||
.text()
|
||||
.replace(/<\s*br.*?>/g, "\n");
|
||||
cqGetChapters.each(function (i, e) {
|
||||
const chapterA = loadedCheerio(this).find("a");
|
||||
const [chapterName, releaseDate, chapterUrl] = [
|
||||
// set the variables
|
||||
chapterA.text(),
|
||||
loadedCheerio(this)
|
||||
.find("dt") // get title
|
||||
.text() // get text
|
||||
.replace(/(.)/g, "") // remove "(edited)" mark
|
||||
.trim(), // trim spaces
|
||||
"https://ncode.syosetu.com" + chapterA.attr("href"),
|
||||
];
|
||||
chapters.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
/**
|
||||
* Because there are oneshots on the site, they have to be treated with special care
|
||||
* that's what pisses me off in Shosetsu app. They have this extension,
|
||||
* but every oneshot is set as "there are no chapters" and all contents are thrown into the description!!
|
||||
*/
|
||||
// get summary for oneshot chapter
|
||||
|
||||
const nameResult = await fetchApi(
|
||||
searchUrl() + `&word=${novel.name}`
|
||||
);
|
||||
const nameBody = await nameResult.text();
|
||||
const summaryQuery = loadCheerio(nameBody, {
|
||||
decodeEntities: false,
|
||||
});
|
||||
const foundText = summaryQuery(".searchkekka_box")
|
||||
.first()
|
||||
.find(".ex")
|
||||
.text()
|
||||
.replace(/\s{2,}/g, "\n");
|
||||
novel.summary = foundText;
|
||||
|
||||
// add single chapter
|
||||
chapters.push({
|
||||
name: "Oneshot",
|
||||
releaseTime: loadedCheerio("head")
|
||||
.find("meta[name='WWWC']")
|
||||
.attr("content"), // get date from metadata
|
||||
url: novelUrl, // set chapterUrl to oneshot so that chapterScraper knows it's a one-shot,
|
||||
});
|
||||
}
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
// create cheerioQuery
|
||||
const cheerioQuery = loadCheerio(body, {
|
||||
decodeEntities: false,
|
||||
});
|
||||
|
||||
let chapterText = cheerioQuery("#novel_honbun") // get chapter text
|
||||
.html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
let novels = [];
|
||||
|
||||
// returns list of novels from given page
|
||||
async function getNovelsFromPage(pagenumber: number) {
|
||||
// load page
|
||||
const result = await fetchApi(
|
||||
searchUrl(pagenumber) + `&word=${searchTerm}`
|
||||
);
|
||||
const body = await result.text();
|
||||
// Cheerio it!
|
||||
const cheerioQuery = loadCheerio(body, { decodeEntities: false });
|
||||
|
||||
let pageNovels: Novel.Item[] = [];
|
||||
// find class=searchkekka_box
|
||||
cheerioQuery(".searchkekka_box").each(function (i, e) {
|
||||
// get div with link and name
|
||||
const novelDIV = cheerioQuery(this).find(".novel_h");
|
||||
// get link element
|
||||
const novelA = novelDIV.children()[0];
|
||||
// add new novel to array
|
||||
pageNovels.push({
|
||||
name: novelDIV.text(), // get the name
|
||||
url: novelA.attribs.href, // get last part of the link
|
||||
cover: defaultCover,
|
||||
});
|
||||
});
|
||||
// return all novels from this page
|
||||
return pageNovels;
|
||||
}
|
||||
|
||||
// counter of loaded pages
|
||||
// let pagesLoaded = 0;
|
||||
// do {
|
||||
// // always load first one
|
||||
// novels.push(...(await getNovelsFromPage(pagesLoaded + 1)));
|
||||
// pagesLoaded++;
|
||||
// } while (pagesLoaded < maxPageLoad && isNext); // check if we should load more
|
||||
|
||||
novels = await getNovelsFromPage(1);
|
||||
|
||||
/** Use
|
||||
* novels.push(...(await getNovelsFromPage(pageNumber)))
|
||||
* if you want to load more
|
||||
*/
|
||||
|
||||
// respond with novels!
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
return await fetchFile(url);
|
||||
};
|
||||
@@ -0,0 +1,147 @@
|
||||
import cheerio from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "agit.xyz";
|
||||
export const name = "Agitoon";
|
||||
export const site = "https://agit501.xyz/";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/kr/agitoon/agit.png";
|
||||
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (page) {
|
||||
const list_limit = 20 * (page - 1);
|
||||
const day = new Date().getDay();
|
||||
|
||||
const res = await fetchApi(baseUrl + "novel/index.update.php", {
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
},
|
||||
body: `mode=get_data_novel_list_p&novel_menu=3&np_day=${day}&np_rank=1&np_distributor=0&np_genre=00&np_order=1&np_genre_ex_1=00&np_genre_ex_2=00&list_limit=${list_limit}&is_query_first=true`,
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
const resJson = await res.json();
|
||||
|
||||
const novels: Novel.Item[] = resJson.list.map((novel) => {
|
||||
return {
|
||||
url: baseUrl + "novel/list/" + novel.wr_id,
|
||||
name: novel.wr_subject,
|
||||
cover: baseUrl + novel.np_dir + "/thumbnail/" + novel.np_thumbnail,
|
||||
};
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const novelId = novelUrl.split("/").reverse()[0];
|
||||
|
||||
// cheerio
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body, { decodeEntities: false });
|
||||
const name = loadedCheerio("h5.pt-2").text();
|
||||
const summary = loadedCheerio(".pt-1.mt-1.pb-1.mb-1").text();
|
||||
const author = loadedCheerio(".post-item-list-cate-v")
|
||||
.first()
|
||||
.text()
|
||||
.split(" : ")
|
||||
.reverse()[0];
|
||||
const cover =
|
||||
baseUrl.slice(0, baseUrl.length - 1) +
|
||||
loadedCheerio("div.col-5.pr-0.pl-0 img").attr("src");
|
||||
const genresTag = loadedCheerio(".col-7 > .post-item-list-cate > span");
|
||||
let genres = "";
|
||||
|
||||
genresTag.each((_, element) => {
|
||||
genres += loadedCheerio(element).text();
|
||||
genres += ", ";
|
||||
});
|
||||
genres = genres.slice(0, genres.length - 2);
|
||||
|
||||
// normal REST HTTP requests
|
||||
let chapters: Chapter.Item[] = [];
|
||||
|
||||
const res = await fetchApi(baseUrl + "novel/list.update.php", {
|
||||
headers: {
|
||||
"content-type":
|
||||
"application/x-www-form-urlencoded; charset=UTF-8",
|
||||
},
|
||||
body: `mode=get_data_novel_list_c&wr_id_p=${novelId}&page_no=1&cnt_list=10000&order_type=Asc`,
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
const resJson = await res.json();
|
||||
|
||||
chapters = resJson.list.map((chapter) => {
|
||||
return {
|
||||
name: chapter.wr_subject,
|
||||
url: baseUrl + `novel/view/${chapter.wr_id}/2`,
|
||||
releaseTime: chapter.wr_datetime,
|
||||
};
|
||||
});
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
name,
|
||||
cover,
|
||||
summary,
|
||||
author,
|
||||
status: "",
|
||||
genres: genres,
|
||||
chapters,
|
||||
};
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const contentTag = loadedCheerio("#id_wr_content > p");
|
||||
|
||||
let content = "";
|
||||
contentTag.each((_, element) => {
|
||||
content += loadedCheerio(element).text();
|
||||
content += "<br />";
|
||||
});
|
||||
|
||||
// gets rid of the popup thingy
|
||||
content = content.replace(
|
||||
"팝업메뉴는 빈공간을 더치하거나 스크룰시 사라집니다",
|
||||
""
|
||||
);
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const rawResults = await fetchApi("https://agit501.xyz/novel/search.php", {
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
},
|
||||
body: `mode=get_data_novel_list_p_sch&search_novel=${searchTerm}&list_limit=0`,
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
const results = await rawResults.json();
|
||||
if (results.list_count === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const novels: Novel.Item[] = results.list.map((result) => {
|
||||
return {
|
||||
url: baseUrl + "novel/list/" + result.wr_id,
|
||||
name: result.wr_subject,
|
||||
cover:
|
||||
baseUrl + result.np_dir + "/thumbnail/" + result.np_thumbnail,
|
||||
};
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
@@ -1,155 +0,0 @@
|
||||
const cheerio = require('cheerio');
|
||||
const fetchApi = require('@libs/fetchApi');
|
||||
const fetchFile = require('@libs/fetchFile');
|
||||
const languages = require('@libs/languages');
|
||||
|
||||
const pluginId = 'agit.xyz';
|
||||
const sourceName = 'Agitoon';
|
||||
const baseUrl = 'https://agit501.xyz/';
|
||||
|
||||
async function popularNovels (page) {
|
||||
const list_limit = 20 * (page - 1);
|
||||
const day = new Date().getDay();
|
||||
|
||||
const res = await fetchApi(baseUrl + 'novel/index.update.php', {
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
body: `mode=get_data_novel_list_p&novel_menu=3&np_day=${day}&np_rank=1&np_distributor=0&np_genre=00&np_order=1&np_genre_ex_1=00&np_genre_ex_2=00&list_limit=${list_limit}&is_query_first=true`,
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
const resJson = await res.json();
|
||||
|
||||
const novels = resJson.list.map(novel => {
|
||||
return {
|
||||
url: baseUrl + 'novel/list/' + novel.wr_id,
|
||||
name: novel.wr_subject,
|
||||
cover: baseUrl + novel.np_dir + '/thumbnail/' + novel.np_thumbnail,
|
||||
};
|
||||
});
|
||||
|
||||
return novels ;
|
||||
};
|
||||
|
||||
async function parseNovelAndChapters (novelUrl) {
|
||||
const novelId = novelUrl.split('/').reverse()[0];
|
||||
|
||||
// cheerio
|
||||
const result = await fetchApi(novelUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body, { decodeEntities: false });
|
||||
const name = loadedCheerio('h5.pt-2').text();
|
||||
const summary = loadedCheerio('.pt-1.mt-1.pb-1.mb-1').text();
|
||||
const author = loadedCheerio('.post-item-list-cate-v')
|
||||
.first()
|
||||
.text()
|
||||
.split(' : ')
|
||||
.reverse()[0];
|
||||
const cover =
|
||||
baseUrl.slice(0, baseUrl.length - 1) +
|
||||
loadedCheerio('div.col-5.pr-0.pl-0 img').attr('src');
|
||||
const genresTag = loadedCheerio('.col-7 > .post-item-list-cate > span');
|
||||
let genres = '';
|
||||
|
||||
genresTag.each((_, element) => {
|
||||
genres += loadedCheerio(element).text();
|
||||
genres += ', ';
|
||||
});
|
||||
genres = genres.slice(0, genres.length - 2);
|
||||
|
||||
// normal REST HTTP requests
|
||||
let chapters = [];
|
||||
|
||||
const res = await fetchApi(baseUrl + 'novel/list.update.php', {
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
body: `mode=get_data_novel_list_c&wr_id_p=${novelId}&page_no=1&cnt_list=10000&order_type=Asc`,
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
const resJson = await res.json();
|
||||
|
||||
chapters = resJson.list.map(chapter => {
|
||||
return {
|
||||
name: chapter.wr_subject,
|
||||
url: baseUrl + `novel/view/${chapter.wr_id}/2`,
|
||||
releaseTime: chapter.wr_datetime,
|
||||
};
|
||||
});
|
||||
|
||||
const novel = {
|
||||
url: novelUrl,
|
||||
name,
|
||||
cover,
|
||||
summary,
|
||||
author,
|
||||
status: '',
|
||||
genres: genres,
|
||||
chapters,
|
||||
};
|
||||
return novel;
|
||||
};
|
||||
|
||||
async function parseChapter (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
|
||||
const contentTag = loadedCheerio('#id_wr_content > p');
|
||||
|
||||
let content = '';
|
||||
contentTag.each((_, element) => {
|
||||
content += loadedCheerio(element).text();
|
||||
content += '<br />';
|
||||
});
|
||||
|
||||
// gets rid of the popup thingy
|
||||
content = content.replace(
|
||||
'팝업메뉴는 빈공간을 더치하거나 스크룰시 사라집니다',
|
||||
'',
|
||||
);
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
async function searchNovels (searchTerm) {
|
||||
const rawResults = await fetchApi('https://agit501.xyz/novel/search.php', {
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
},
|
||||
body: `mode=get_data_novel_list_p_sch&search_novel=${searchTerm}&list_limit=0`,
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
const results = await rawResults.json();
|
||||
if (results.list_count === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const novels = results.list.map(result => {
|
||||
return {
|
||||
url: baseUrl + 'novel/list/' + result.wr_id,
|
||||
name: result.wr_subject,
|
||||
cover: baseUrl + result.np_dir + '/thumbnail/' + result.np_thumbnail,
|
||||
};
|
||||
});
|
||||
return novels;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: '1.0.0',
|
||||
icon: 'src/kr/agitoon/agit.png',
|
||||
lang: languages.Korean,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
@@ -0,0 +1,421 @@
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { FilterInputs } from "@libs/filterInputs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
|
||||
export const id = "lightnovelbrasil";
|
||||
export const name = "Light Novel Brasil";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "multisrc/wpmangastream/icons/lightnovelbrasil.png";
|
||||
export const site = "https://lightnovelbrasil.com/";
|
||||
exports.protected = false;
|
||||
|
||||
const pluginId = id;
|
||||
const baseUrl = site;
|
||||
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ filters }
|
||||
) {
|
||||
let link = `${baseUrl}series/?page=${page}`;
|
||||
|
||||
if (filters) {
|
||||
if (Array.isArray(filters.genres) && filters.genres.length) {
|
||||
link += filters.genres.map((i) => `&genre[]=${i}`).join("");
|
||||
}
|
||||
|
||||
if (Array.isArray(filters.type) && filters.type.length) {
|
||||
link += filters.type.map((i) => `&lang[]=${i}`).join("");
|
||||
}
|
||||
}
|
||||
|
||||
link += "&status=" + (filters?.status ? filters?.status : "");
|
||||
|
||||
link += "&order=" + (filters?.order ? filters?.order : "popular");
|
||||
|
||||
const body = await fetchApi(link, {}, pluginId).then((result) =>
|
||||
result.text()
|
||||
);
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.bs").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".ntitle").text().trim();
|
||||
let image = loadedCheerio(this).find("img");
|
||||
const novelCover = image.attr("data-src") || image.attr("src");
|
||||
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
|
||||
const novel = {
|
||||
name: novelName,
|
||||
cover: novelCover,
|
||||
url: novelUrl,
|
||||
};
|
||||
|
||||
novels.push(novel);
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const url = novelUrl;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
let loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Novel.instance = {
|
||||
url,
|
||||
chapters: [],
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".entry-title").text();
|
||||
|
||||
novel.cover =
|
||||
loadedCheerio("img.wp-post-image").attr("data-src") ||
|
||||
loadedCheerio("img.wp-post-image").attr("src");
|
||||
|
||||
loadedCheerio("div.spe > span").each(function () {
|
||||
const detailName = loadedCheerio(this).find("b").text().trim();
|
||||
const detail = loadedCheerio(this)
|
||||
.find("b")
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
switch (detailName) {
|
||||
case "المؤلف:":
|
||||
case "Yazar:":
|
||||
case "Autor:":
|
||||
case "Author:":
|
||||
novel.author = detail;
|
||||
break;
|
||||
case "Status:":
|
||||
case "Seviye:":
|
||||
novel.status = detail;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
novel.genres = loadedCheerio(".genxed")
|
||||
.text()
|
||||
.trim()
|
||||
.replace(/\s/g, ",");
|
||||
|
||||
loadedCheerio('div[itemprop="description"] h3,p.a,strong').remove();
|
||||
novel.summary = loadedCheerio('div[itemprop="description"]')
|
||||
.find("br")
|
||||
.replaceWith("\n")
|
||||
.end()
|
||||
.text();
|
||||
|
||||
let chapter: Chapter.Item[] = [];
|
||||
|
||||
loadedCheerio(".eplister")
|
||||
.find("li")
|
||||
.each(function () {
|
||||
const chapterName =
|
||||
loadedCheerio(this).find(".epl-num").text() +
|
||||
" - " +
|
||||
loadedCheerio(this).find(".epl-title").text();
|
||||
|
||||
const releaseDate = loadedCheerio(this)
|
||||
.find(".epl-date")
|
||||
.text()
|
||||
.trim();
|
||||
|
||||
const chapterUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!chapterUrl) return;
|
||||
|
||||
chapter.push({
|
||||
name: chapterName,
|
||||
releaseTime: releaseDate,
|
||||
url: chapterUrl,
|
||||
});
|
||||
});
|
||||
|
||||
novel.chapters = chapter.reverse();
|
||||
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
let chapterText = loadedCheerio("div.epcontent").html();
|
||||
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}?s=${searchTerm}`;
|
||||
|
||||
const result = await fetchApi(url, {}, pluginId);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("article.bs").each(function () {
|
||||
const novelName = loadedCheerio(this).find(".ntitle").text().trim();
|
||||
const novelCover = loadedCheerio(this).find("img").attr("src");
|
||||
const novelUrl = loadedCheerio(this).find("a").attr("href");
|
||||
|
||||
if (!novelUrl) return;
|
||||
novels.push({
|
||||
name: novelName,
|
||||
url: novelUrl,
|
||||
cover: novelCover,
|
||||
});
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const fetchImage: Plugin.fetchImage = async function (url) {
|
||||
const headers = {
|
||||
Referer: baseUrl,
|
||||
};
|
||||
return await fetchFile(url, { headers: headers });
|
||||
};
|
||||
|
||||
export const filters = [
|
||||
{
|
||||
key: "order",
|
||||
label: "Sort By",
|
||||
values: [
|
||||
{ label: "Default", value: "" },
|
||||
|
||||
{ label: "A-Z", value: "title" },
|
||||
|
||||
{ label: "Z-A", value: "titlereverse" },
|
||||
|
||||
{ label: "Latest Update", value: "update" },
|
||||
|
||||
{ label: "Latest Added", value: "latest" },
|
||||
|
||||
{ label: "Popular", value: "popular" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
label: "Status",
|
||||
values: [
|
||||
{ label: "All", value: "" },
|
||||
|
||||
{ label: "Ongoing", value: "ongoing" },
|
||||
|
||||
{ label: "Hiatus", value: "hiatus" },
|
||||
|
||||
{ label: "Completed", value: "completed" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "type",
|
||||
label: "Type",
|
||||
values: [
|
||||
{ label: "Chinese novel", value: "chinese-novel" },
|
||||
|
||||
{ label: "habyeol", value: "habyeol" },
|
||||
|
||||
{ label: "korean novel", value: "korean-novel" },
|
||||
|
||||
{ label: "Web Novel", value: "web-novel" },
|
||||
|
||||
{ label: "삼심", value: "%ec%82%bc%ec%8b%ac" },
|
||||
|
||||
{ label: "호곡", value: "%ed%98%b8%ea%b3%a1" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
{
|
||||
key: "genres",
|
||||
label: "Genres",
|
||||
values: [
|
||||
{ label: "A.I", value: "a.i" },
|
||||
|
||||
{ label: "Academy", value: "academy" },
|
||||
|
||||
{ label: "Action", value: "action" },
|
||||
|
||||
{ label: "Adult", value: "adult" },
|
||||
|
||||
{ label: "Adventure", value: "adventure" },
|
||||
|
||||
{ label: "Alternative History", value: "alternative-history" },
|
||||
|
||||
{ label: "Another World", value: "another-world" },
|
||||
|
||||
{ label: "Apocalypse", value: "apocalypse" },
|
||||
|
||||
{ label: "Bromance", value: "bromance" },
|
||||
|
||||
{ label: "Comedy", value: "comedy" },
|
||||
|
||||
{ label: "Dark fantasy", value: "dark-fantasy" },
|
||||
|
||||
{ label: "Demons", value: "demons" },
|
||||
|
||||
{ label: "Drama", value: "drama" },
|
||||
|
||||
{ label: "Dystopia", value: "dystopia" },
|
||||
|
||||
{ label: "Ecchi", value: "ecchi" },
|
||||
|
||||
{ label: "Entertainment", value: "entertainment" },
|
||||
|
||||
{ label: "Exhaustion", value: "exhaustion" },
|
||||
|
||||
{ label: "Fanfiction", value: "fanfiction" },
|
||||
|
||||
{ label: "fantasy", value: "fantasy" },
|
||||
|
||||
{ label: "finance", value: "finance" },
|
||||
|
||||
{ label: "Full color", value: "full-color" },
|
||||
|
||||
{ label: "Game", value: "game" },
|
||||
|
||||
{ label: "Gender Bender", value: "gender-bender" },
|
||||
|
||||
{ label: "Genius", value: "genius" },
|
||||
|
||||
{ label: "Harem", value: "harem" },
|
||||
|
||||
{ label: "Hero", value: "hero" },
|
||||
|
||||
{ label: "Historical", value: "historical" },
|
||||
|
||||
{ label: "Hunter", value: "hunter" },
|
||||
|
||||
{ label: "korean novel", value: "korean-novel" },
|
||||
|
||||
{ label: "Light Novel", value: "light-novel" },
|
||||
|
||||
{
|
||||
label: "List Adventure Manga Genres",
|
||||
value: "list-adventure-manga-genres",
|
||||
},
|
||||
|
||||
{ label: "Long Strip", value: "long-strip" },
|
||||
|
||||
{ label: "Love comedy", value: "love-comedy" },
|
||||
|
||||
{ label: "magic", value: "magic" },
|
||||
|
||||
{ label: "Manhua", value: "manhua" },
|
||||
|
||||
{ label: "Martial Arts", value: "martial-arts" },
|
||||
|
||||
{ label: "Mature", value: "mature" },
|
||||
|
||||
{ label: "Medieval", value: "medieval" },
|
||||
|
||||
{ label: "Misunderstanding", value: "misunderstanding" },
|
||||
|
||||
{ label: "Modern", value: "modern" },
|
||||
|
||||
{ label: "modern fantasy", value: "modern-fantasy" },
|
||||
|
||||
{ label: "music", value: "music" },
|
||||
|
||||
{ label: "Mystery", value: "mystery" },
|
||||
|
||||
{ label: "Necromancy", value: "necromancy" },
|
||||
|
||||
{ label: "No Romance", value: "no-romance" },
|
||||
|
||||
{ label: "NTL", value: "ntl" },
|
||||
|
||||
{ label: "o", value: "o" },
|
||||
|
||||
{ label: "Obsession", value: "obsession" },
|
||||
|
||||
{ label: "Politics", value: "politics" },
|
||||
|
||||
{ label: "Possession", value: "possession" },
|
||||
|
||||
{ label: "Programming", value: "programming" },
|
||||
|
||||
{ label: "Psychological", value: "psychological" },
|
||||
|
||||
{ label: "Pure Love", value: "pure-love" },
|
||||
|
||||
{ label: "Redemption", value: "redemption" },
|
||||
|
||||
{ label: "Regression", value: "regression" },
|
||||
|
||||
{ label: "Regret", value: "regret" },
|
||||
|
||||
{ label: "Reincarnation", value: "reincarnation" },
|
||||
|
||||
{ label: "Revenge", value: "revenge" },
|
||||
|
||||
{ label: "Romance", value: "romance" },
|
||||
|
||||
{ label: "Romance Fanrasy", value: "romance-fanrasy" },
|
||||
|
||||
{ label: "Salvation", value: "salvation" },
|
||||
|
||||
{ label: "School Life", value: "school-life" },
|
||||
|
||||
{ label: "Sci-fi", value: "sci-fi" },
|
||||
|
||||
{ label: "Science fiction", value: "science-fiction" },
|
||||
|
||||
{ label: "Seinen", value: "seinen" },
|
||||
|
||||
{ label: "Shounen", value: "shounen" },
|
||||
|
||||
{ label: "Slice of Life", value: "slice-of-life" },
|
||||
|
||||
{ label: "Soft yandere", value: "soft-yandere" },
|
||||
|
||||
{ label: "Sports", value: "sports" },
|
||||
|
||||
{ label: "Supernatural", value: "supernatural" },
|
||||
|
||||
{ label: "Survival", value: "survival" },
|
||||
|
||||
{ label: "system", value: "system" },
|
||||
|
||||
{ label: "Time limit", value: "time-limit" },
|
||||
|
||||
{ label: "Tragedy", value: "tragedy" },
|
||||
|
||||
{ label: "Transmigration", value: "transmigration" },
|
||||
|
||||
{ label: "TS", value: "ts" },
|
||||
|
||||
{ label: "Tsundere", value: "tsundere" },
|
||||
|
||||
{ label: "Unique", value: "unique" },
|
||||
|
||||
{ label: "Wholesome", value: "wholesome" },
|
||||
|
||||
{ label: "Wuxia", value: "wuxia" },
|
||||
|
||||
{ label: "Xuanhuan", value: "xuanhuan" },
|
||||
|
||||
{ label: "Yandere", value: "yandere" },
|
||||
|
||||
{ label: "Yuri", value: "yuri" },
|
||||
],
|
||||
inputType: FilterInputs.Checkbox,
|
||||
},
|
||||
];
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,341 @@
|
||||
import cheerio from "cheerio";
|
||||
import dayjs from "dayjs";
|
||||
import { fetchApi } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import { FilterInputs } from "@libs/filterInputs";
|
||||
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
||||
import { defaultCover } from "@libs/defaultCover";
|
||||
|
||||
export const id = "AT";
|
||||
export const name = "Автор Тудей";
|
||||
export const site = "https://author.today";
|
||||
export const version = "1.0.0";
|
||||
export const icon = "src/ru/authortoday/icon.png";
|
||||
|
||||
const baseUrl = site;
|
||||
const apiUrl = "https://api.author.today/";
|
||||
|
||||
const token = "Bearer guest";
|
||||
export const popularNovels: Plugin.popularNovels = async function (
|
||||
page,
|
||||
{ showLatestNovels, filters }
|
||||
) {
|
||||
let url = apiUrl + "v1/catalog/search?page=" + page;
|
||||
if (filters?.genre) {
|
||||
url += "&genre=" + filters.genre;
|
||||
}
|
||||
|
||||
url +=
|
||||
"&sorting=" +
|
||||
(showLatestNovels ? "recent" : filters?.sort || "popular");
|
||||
|
||||
url += "&form=" + (filters?.form || "any");
|
||||
url += "&state=" + (filters?.state || "any");
|
||||
url += "&series=" + (filters?.series || "any");
|
||||
url += "&access=" + (filters?.access || "any");
|
||||
url += "&promo=" + (filters?.promo || "hide");
|
||||
|
||||
const result = await fetchApi(url, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
const json = await result.json();
|
||||
|
||||
if (json?.code === "NotFound") {
|
||||
return [];
|
||||
}
|
||||
|
||||
let novels: Novel.Item[] = [];
|
||||
json.searchResults.forEach((novel) =>
|
||||
novels.push({
|
||||
name: novel.title,
|
||||
cover: novel?.coverUrl
|
||||
? "https://cm.author.today/content/" + novel.coverUrl
|
||||
: defaultCover,
|
||||
url: baseUrl + "/work/" + novel.id,
|
||||
})
|
||||
);
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
||||
async function (novelUrl) {
|
||||
const workID = novelUrl.split("/")[4];
|
||||
let result = await fetchApi(`${apiUrl}v1/work/${workID}/details`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
|
||||
let json = await result.json();
|
||||
let novel: Novel.instance = {
|
||||
url: novelUrl,
|
||||
name: json.title,
|
||||
cover: json?.coverUrl ? json.coverUrl.split("?")[0] : defaultCover,
|
||||
author:
|
||||
json?.originalAuthor ||
|
||||
json?.authorFIO ||
|
||||
json?.coAuthorFIO ||
|
||||
json?.secondCoAuthorFIO ||
|
||||
json?.translator ||
|
||||
"",
|
||||
genres: json?.tags?.join(", "),
|
||||
status: json?.isFinished
|
||||
? NovelStatus.Completed
|
||||
: NovelStatus.Ongoing,
|
||||
};
|
||||
|
||||
novel.summary = "";
|
||||
novel.summary += json?.annotation ? json.annotation + "\n" : "";
|
||||
novel.summary += json?.authorNotes
|
||||
? "Примечания автора:\n" + json.authorNotes
|
||||
: "";
|
||||
// all chapters
|
||||
result = await fetchApi(`${apiUrl}v1/work/${workID}/content`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
json = await result.json();
|
||||
|
||||
let chapters: Chapter.Item[] = [];
|
||||
json?.forEach((chapter, index) => {
|
||||
if (chapter?.isAvailable && !chapter?.isDraft) {
|
||||
chapters.push({
|
||||
name: chapter?.title || `Глава ${index + 1}`,
|
||||
releaseTime: dayjs(
|
||||
chapter?.publishTime || chapter.lastModificationTime
|
||||
).format("LLL"),
|
||||
url: `${apiUrl}v1/work/${workID}/chapter/${chapter.id}/text`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
};
|
||||
|
||||
export const parseChapter: Plugin.parseChapter = async function (chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
const json = await result.json();
|
||||
|
||||
if (json?.code) {
|
||||
return json.code + "\n" + json?.message;
|
||||
}
|
||||
|
||||
let key = json.key.split("").reverse().join("") + "@_@";
|
||||
let text = "";
|
||||
|
||||
for (let i = 0; i < json.text.length; i++) {
|
||||
text += String.fromCharCode(
|
||||
json.text.charCodeAt(i) ^ key.charCodeAt(Math.floor(i % key.length))
|
||||
);
|
||||
}
|
||||
|
||||
const loadedCheerio = cheerio.load(text);
|
||||
loadedCheerio("img").each(function () {
|
||||
if (!loadedCheerio(this).attr("src")?.startsWith("http")) {
|
||||
const src = loadedCheerio(this).attr("src");
|
||||
loadedCheerio(this).attr("src", baseUrl + src);
|
||||
}
|
||||
});
|
||||
const chapterText = loadedCheerio.html();
|
||||
return chapterText;
|
||||
};
|
||||
|
||||
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
||||
const url = `${baseUrl}/search?category=works&q=${searchTerm}`;
|
||||
const result = await fetchApi(url, {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0",
|
||||
referer: baseUrl,
|
||||
});
|
||||
const body = await result.text();
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
let novels: Novel.Item[] = [];
|
||||
|
||||
loadedCheerio("div.book-row").each(function () {
|
||||
const name = loadedCheerio(this)
|
||||
.find('div[class="book-title"] a')
|
||||
.text()
|
||||
.trim();
|
||||
let cover = loadedCheerio(this).find("img").attr("src");
|
||||
const url =
|
||||
baseUrl +
|
||||
"/work/" +
|
||||
loadedCheerio(this)
|
||||
.find('div[class="book-title"] a')
|
||||
.attr("href")
|
||||
?.split("/")[2];
|
||||
|
||||
if (cover) {
|
||||
cover = cover.split("?")[0];
|
||||
} else {
|
||||
cover = defaultCover;
|
||||
}
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
});
|
||||
|
||||
return novels;
|
||||
};
|
||||
|
||||
export const filters = [
|
||||
{
|
||||
key: "sort",
|
||||
label: "Сортировка",
|
||||
values: [
|
||||
{ label: "По популярности", value: "popular" },
|
||||
{ label: "По количеству лайков", value: "likes" },
|
||||
{ label: "По комментариям", value: "comments" },
|
||||
{ label: "По новизне", value: "recent" },
|
||||
{ label: "По просмотрам", value: "views" },
|
||||
{ label: "Набирающие популярность", value: "trending" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "genre",
|
||||
label: "Жанры",
|
||||
values: [
|
||||
{ label: "Альтернативная история", value: "sf-history" },
|
||||
{ label: "Антиутопия", value: "dystopia" },
|
||||
{ label: "Бизнес-литература", value: "biznes-literatura" },
|
||||
{ label: "Боевая фантастика", value: "sf-action" },
|
||||
{ label: "Боевик", value: "action" },
|
||||
{ label: "Боевое фэнтези", value: "fantasy-action" },
|
||||
{ label: "Бояръ-Аниме", value: "boyar-anime" },
|
||||
{ label: "Героическая фантастика", value: "sf-heroic" },
|
||||
{ label: "Героическое фэнтези", value: "heroic-fantasy" },
|
||||
{ label: "Городское фэнтези", value: "urban-fantasy" },
|
||||
{ label: "Детектив", value: "detective" },
|
||||
{ label: "Детская литература", value: "detskaya-literatura" },
|
||||
{ label: "Документальная проза", value: "non-fiction" },
|
||||
{ label: "Историческая проза", value: "historical-fiction" },
|
||||
{
|
||||
label: "Исторические приключения",
|
||||
value: "historical-adventure",
|
||||
},
|
||||
{ label: "Исторический детектив", value: "historical-mystery" },
|
||||
{
|
||||
label: "Исторический любовный роман",
|
||||
value: "historical-romance",
|
||||
},
|
||||
{ label: "Историческое фэнтези", value: "historical-fantasy" },
|
||||
{ label: "Киберпанк", value: "cyberpunk" },
|
||||
{ label: "Короткий любовный роман", value: "short-romance" },
|
||||
{ label: "Космическая фантастика", value: "sf-space" },
|
||||
{ label: "ЛитРПГ", value: "litrpg" },
|
||||
{ label: "Любовное фэнтези", value: "love-fantasy" },
|
||||
{ label: "Любовные романы", value: "romance" },
|
||||
{ label: "Мистика", value: "paranormal" },
|
||||
{ label: "Назад в СССР", value: "back-to-ussr" },
|
||||
{ label: "Научная фантастика", value: "science-fiction" },
|
||||
{ label: "Подростковая проза", value: "teen-prose" },
|
||||
{ label: "Политический роман", value: "political-fiction" },
|
||||
{ label: "Попаданцы", value: "popadantsy" },
|
||||
{ label: "Попаданцы в космос", value: "popadantsy-v-kosmos" },
|
||||
{
|
||||
label: "Попаданцы в магические миры",
|
||||
value: "popadantsy-v-magicheskie-miry",
|
||||
},
|
||||
{ label: "Попаданцы во времени", value: "popadantsy-vo-vremeni" },
|
||||
{ label: "Постапокалипсис", value: "postapocalyptic" },
|
||||
{ label: "Поэзия", value: "poetry" },
|
||||
{ label: "Приключения", value: "adventure" },
|
||||
{ label: "Публицистика", value: "publicism" },
|
||||
{ label: "Развитие личности", value: "razvitie-lichnosti" },
|
||||
{ label: "Разное", value: "other" },
|
||||
{ label: "РеалРПГ", value: "realrpg" },
|
||||
{ label: "Романтическая эротика", value: "romantic-erotika" },
|
||||
{ label: "Сказка", value: "fairy-tale" },
|
||||
{ label: "Современная проза", value: "modern-prose" },
|
||||
{
|
||||
label: "Современный любовный роман",
|
||||
value: "contemporary-romance",
|
||||
},
|
||||
{ label: "Социальная фантастика", value: "sf-social" },
|
||||
{ label: "Стимпанк", value: "steampunk" },
|
||||
{ label: "Темное фэнтези", value: "dark-fantasy" },
|
||||
{ label: "Триллер", value: "thriller" },
|
||||
{ label: "Ужасы", value: "horror" },
|
||||
{ label: "Фантастика", value: "sci-fi" },
|
||||
{
|
||||
label: "Фантастический детектив",
|
||||
value: "detective-science-fiction",
|
||||
},
|
||||
{ label: "Фанфик", value: "fanfiction" },
|
||||
{ label: "Фэнтези", value: "fantasy" },
|
||||
{ label: "Шпионский детектив", value: "spy-mystery" },
|
||||
{ label: "Эпическое фэнтези", value: "epic-fantasy" },
|
||||
{ label: "Эротика", value: "erotica" },
|
||||
{ label: "Эротическая фантастика", value: "sf-erotika" },
|
||||
{ label: "Эротический фанфик", value: "fanfiction-erotika" },
|
||||
{ label: "Эротическое фэнтези", value: "fantasy-erotika" },
|
||||
{ label: "Юмор", value: "humor" },
|
||||
{ label: "Юмористическая фантастика", value: "sf-humor" },
|
||||
{ label: "Юмористическое фэнтези", value: "ironical-fantasy" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "form",
|
||||
label: "Форма произведения",
|
||||
values: [
|
||||
{ label: "Любой", value: "any" },
|
||||
{ label: "Перевод", value: "translation" },
|
||||
{ label: "Повесть", value: "tale" },
|
||||
{ label: "Рассказ", value: "story" },
|
||||
{ label: "Роман", value: "novel" },
|
||||
{ label: "Сборник поэзии", value: "poetry" },
|
||||
{ label: "Сборник рассказов", value: "story-book" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "state",
|
||||
label: "Статус произведения",
|
||||
values: [
|
||||
{ label: "Любой статус", value: "any" },
|
||||
{ label: "В процессе", value: "in-progress" },
|
||||
{ label: "Завершено", value: "finished" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "series",
|
||||
label: "Статус цикла",
|
||||
values: [
|
||||
{ label: "Не важно", value: "any" },
|
||||
{ label: "Вне цикла", value: "out" },
|
||||
{ label: "Цикл завершен", value: "finished" },
|
||||
{ label: "Цикл не завершен", value: "unfinished" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "access",
|
||||
label: "Тип доступа",
|
||||
values: [
|
||||
{ label: "Любой", value: "any" },
|
||||
{ label: "Платный", value: "paid" },
|
||||
{ label: "Бесплатный", value: "free" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "promo",
|
||||
label: "Промо-фрагмент",
|
||||
values: [
|
||||
{ label: "Скрывать", value: "hide" },
|
||||
{ label: "Показывать", value: "show" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
];
|
||||
@@ -1,336 +0,0 @@
|
||||
const cheerio = require("cheerio");
|
||||
const dayjs = require("dayjs");
|
||||
const fetchApi = require("@libs/fetchApi");
|
||||
const fetchFile = require("@libs/fetchFile");
|
||||
const languages = require("@libs/languages");
|
||||
const Status = require("@libs/novelStatus");
|
||||
const FilterInputs = require("@libs/filterInputs");
|
||||
const defaultCoverUri =
|
||||
"https://github.com/LNReader/lnreader-sources/blob/main/icons/src/coverNotAvailable.jpg?raw=true";
|
||||
|
||||
const pluginId = "AT";
|
||||
const sourceName = "Автор Тудей";
|
||||
|
||||
const baseUrl = "https://author.today";
|
||||
const apiUrl = "https://api.author.today/";
|
||||
|
||||
const token = "Bearer guest";
|
||||
async function popularNovels(page, { showLatestNovels, filters }) {
|
||||
let url = apiUrl + "v1/catalog/search?page=" + page;
|
||||
if (filters?.genre) {
|
||||
url += "&genre=" + filters.genre;
|
||||
}
|
||||
|
||||
url +=
|
||||
"&sorting=" + (showLatestNovels ? "recent" : filters?.sort || "popular");
|
||||
|
||||
url += "&form=" + (filters?.form || "any");
|
||||
url += "&state=" + (filters?.state || "any");
|
||||
url += "&series=" + (filters?.series || "any");
|
||||
url += "&access=" + (filters?.access || "any");
|
||||
url += "&promo=" + (filters?.promo || "hide");
|
||||
|
||||
const result = await fetchApi(url, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
const json = await result.json();
|
||||
|
||||
if (json?.code === "NotFound") {
|
||||
return [];
|
||||
}
|
||||
|
||||
let novels = [];
|
||||
json.searchResults.forEach((novel) =>
|
||||
novels.push({
|
||||
name: novel.title,
|
||||
cover: novel?.coverUrl
|
||||
? "https://cm.author.today/content/" + novel.coverUrl
|
||||
: defaultCoverUri,
|
||||
url: baseUrl + "/work/" + novel.id,
|
||||
})
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async function parseNovelAndChapters(novelUrl) {
|
||||
const workID = novelUrl.split("/")[4];
|
||||
let result = await fetchApi(`${apiUrl}v1/work/${workID}/details`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
|
||||
let json = await result.json();
|
||||
let novel = {
|
||||
url: novelUrl,
|
||||
name: json.title,
|
||||
cover: json?.coverUrl ? json.coverUrl.split("?")[0] : defaultCoverUri,
|
||||
author:
|
||||
json?.originalAuthor ||
|
||||
json?.authorFIO ||
|
||||
json?.coAuthorFIO ||
|
||||
json?.secondCoAuthorFIO ||
|
||||
json?.translator ||
|
||||
"",
|
||||
genres: json?.tags?.join(", "),
|
||||
status: json?.isFinished ? Status.Completed : Status.Ongoing,
|
||||
};
|
||||
|
||||
novel.summary = "";
|
||||
novel.summary += json?.annotation ? json.annotation + "\n" : "";
|
||||
novel.summary += json?.authorNotes
|
||||
? "Примечания автора:\n" + json.authorNotes
|
||||
: "";
|
||||
// all chapters
|
||||
result = await fetchApi(`${apiUrl}v1/work/${workID}/content`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
json = await result.json();
|
||||
|
||||
let chapters = [];
|
||||
json?.forEach((chapter, index) => {
|
||||
if (chapter?.isAvailable && !chapter?.isDraft) {
|
||||
chapters.push({
|
||||
name: chapter?.title || `Глава ${index + 1}`,
|
||||
releaseTime: dayjs(
|
||||
chapter?.publishTime || chapter.lastModificationTime
|
||||
).format("LLL"),
|
||||
url: `${apiUrl}v1/work/${workID}/chapter/${chapter.id}/text`,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async function parseChapter(chapterUrl) {
|
||||
const result = await fetchApi(chapterUrl, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
});
|
||||
const json = await result.json();
|
||||
|
||||
if (json?.code) {
|
||||
return json.code + "\n" + json?.message;
|
||||
}
|
||||
|
||||
let key = json.key.split("").reverse().join("") + "@_@";
|
||||
let text = "";
|
||||
|
||||
for (let i = 0; i < json.text.length; i++) {
|
||||
text += String.fromCharCode(
|
||||
json.text.charCodeAt(i) ^ key.charCodeAt(Math.floor(i % key.length))
|
||||
);
|
||||
}
|
||||
|
||||
const loadedCheerio = cheerio.load(text);
|
||||
loadedCheerio("img").each(function () {
|
||||
if (!loadedCheerio(this).attr("src")?.startsWith("http")) {
|
||||
const src = loadedCheerio(this).attr("src");
|
||||
loadedCheerio(this).attr("src", baseUrl + src);
|
||||
}
|
||||
});
|
||||
const chapterText = loadedCheerio.html();
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async function searchNovels(searchTerm) {
|
||||
const url = `${baseUrl}/search?category=works&q=${searchTerm}`;
|
||||
const result = await fetchApi(url, {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0",
|
||||
referer: baseUrl,
|
||||
});
|
||||
const body = await result.text();
|
||||
const loadedCheerio = cheerio.load(body);
|
||||
let novels = [];
|
||||
|
||||
loadedCheerio("div.book-row").each(function () {
|
||||
const name = loadedCheerio(this)
|
||||
.find('div[class="book-title"] a')
|
||||
.text()
|
||||
.trim();
|
||||
let cover = loadedCheerio(this).find("img").attr("src");
|
||||
const url =
|
||||
baseUrl +
|
||||
"/work/" +
|
||||
loadedCheerio(this)
|
||||
.find('div[class="book-title"] a')
|
||||
.attr("href")
|
||||
.split("/")[2];
|
||||
|
||||
if (cover) {
|
||||
cover = cover.split("?")[0];
|
||||
} else {
|
||||
cover = defaultCoverUri;
|
||||
}
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
const filters = [
|
||||
{
|
||||
key: "sort",
|
||||
label: "Сортировка",
|
||||
values: [
|
||||
{ label: "По популярности", value: "popular" },
|
||||
{ label: "По количеству лайков", value: "likes" },
|
||||
{ label: "По комментариям", value: "comments" },
|
||||
{ label: "По новизне", value: "recent" },
|
||||
{ label: "По просмотрам", value: "views" },
|
||||
{ label: "Набирающие популярность", value: "trending" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "genre",
|
||||
label: "Жанры",
|
||||
values: [
|
||||
{ label: "Альтернативная история", value: "sf-history" },
|
||||
{ label: "Антиутопия", value: "dystopia" },
|
||||
{ label: "Бизнес-литература", value: "biznes-literatura" },
|
||||
{ label: "Боевая фантастика", value: "sf-action" },
|
||||
{ label: "Боевик", value: "action" },
|
||||
{ label: "Боевое фэнтези", value: "fantasy-action" },
|
||||
{ label: "Бояръ-Аниме", value: "boyar-anime" },
|
||||
{ label: "Героическая фантастика", value: "sf-heroic" },
|
||||
{ label: "Героическое фэнтези", value: "heroic-fantasy" },
|
||||
{ label: "Городское фэнтези", value: "urban-fantasy" },
|
||||
{ label: "Детектив", value: "detective" },
|
||||
{ label: "Детская литература", value: "detskaya-literatura" },
|
||||
{ label: "Документальная проза", value: "non-fiction" },
|
||||
{ label: "Историческая проза", value: "historical-fiction" },
|
||||
{ label: "Исторические приключения", value: "historical-adventure" },
|
||||
{ label: "Исторический детектив", value: "historical-mystery" },
|
||||
{ label: "Исторический любовный роман", value: "historical-romance" },
|
||||
{ label: "Историческое фэнтези", value: "historical-fantasy" },
|
||||
{ label: "Киберпанк", value: "cyberpunk" },
|
||||
{ label: "Короткий любовный роман", value: "short-romance" },
|
||||
{ label: "Космическая фантастика", value: "sf-space" },
|
||||
{ label: "ЛитРПГ", value: "litrpg" },
|
||||
{ label: "Любовное фэнтези", value: "love-fantasy" },
|
||||
{ label: "Любовные романы", value: "romance" },
|
||||
{ label: "Мистика", value: "paranormal" },
|
||||
{ label: "Назад в СССР", value: "back-to-ussr" },
|
||||
{ label: "Научная фантастика", value: "science-fiction" },
|
||||
{ label: "Подростковая проза", value: "teen-prose" },
|
||||
{ label: "Политический роман", value: "political-fiction" },
|
||||
{ label: "Попаданцы", value: "popadantsy" },
|
||||
{ label: "Попаданцы в космос", value: "popadantsy-v-kosmos" },
|
||||
{
|
||||
label: "Попаданцы в магические миры",
|
||||
value: "popadantsy-v-magicheskie-miry",
|
||||
},
|
||||
{ label: "Попаданцы во времени", value: "popadantsy-vo-vremeni" },
|
||||
{ label: "Постапокалипсис", value: "postapocalyptic" },
|
||||
{ label: "Поэзия", value: "poetry" },
|
||||
{ label: "Приключения", value: "adventure" },
|
||||
{ label: "Публицистика", value: "publicism" },
|
||||
{ label: "Развитие личности", value: "razvitie-lichnosti" },
|
||||
{ label: "Разное", value: "other" },
|
||||
{ label: "РеалРПГ", value: "realrpg" },
|
||||
{ label: "Романтическая эротика", value: "romantic-erotika" },
|
||||
{ label: "Сказка", value: "fairy-tale" },
|
||||
{ label: "Современная проза", value: "modern-prose" },
|
||||
{ label: "Современный любовный роман", value: "contemporary-romance" },
|
||||
{ label: "Социальная фантастика", value: "sf-social" },
|
||||
{ label: "Стимпанк", value: "steampunk" },
|
||||
{ label: "Темное фэнтези", value: "dark-fantasy" },
|
||||
{ label: "Триллер", value: "thriller" },
|
||||
{ label: "Ужасы", value: "horror" },
|
||||
{ label: "Фантастика", value: "sci-fi" },
|
||||
{ label: "Фантастический детектив", value: "detective-science-fiction" },
|
||||
{ label: "Фанфик", value: "fanfiction" },
|
||||
{ label: "Фэнтези", value: "fantasy" },
|
||||
{ label: "Шпионский детектив", value: "spy-mystery" },
|
||||
{ label: "Эпическое фэнтези", value: "epic-fantasy" },
|
||||
{ label: "Эротика", value: "erotica" },
|
||||
{ label: "Эротическая фантастика", value: "sf-erotika" },
|
||||
{ label: "Эротический фанфик", value: "fanfiction-erotika" },
|
||||
{ label: "Эротическое фэнтези", value: "fantasy-erotika" },
|
||||
{ label: "Юмор", value: "humor" },
|
||||
{ label: "Юмористическая фантастика", value: "sf-humor" },
|
||||
{ label: "Юмористическое фэнтези", value: "ironical-fantasy" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "form",
|
||||
label: "Форма произведения",
|
||||
values: [
|
||||
{ label: "Любой", value: "any" },
|
||||
{ label: "Перевод", value: "translation" },
|
||||
{ label: "Повесть", value: "tale" },
|
||||
{ label: "Рассказ", value: "story" },
|
||||
{ label: "Роман", value: "novel" },
|
||||
{ label: "Сборник поэзии", value: "poetry" },
|
||||
{ label: "Сборник рассказов", value: "story-book" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "state",
|
||||
label: "Статус произведения",
|
||||
values: [
|
||||
{ label: "Любой статус", value: "any" },
|
||||
{ label: "В процессе", value: "in-progress" },
|
||||
{ label: "Завершено", value: "finished" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "series",
|
||||
label: "Статус цикла",
|
||||
values: [
|
||||
{ label: "Не важно", value: "any" },
|
||||
{ label: "Вне цикла", value: "out" },
|
||||
{ label: "Цикл завершен", value: "finished" },
|
||||
{ label: "Цикл не завершен", value: "unfinished" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "access",
|
||||
label: "Тип доступа",
|
||||
values: [
|
||||
{ label: "Любой", value: "any" },
|
||||
{ label: "Платный", value: "paid" },
|
||||
{ label: "Бесплатный", value: "free" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
{
|
||||
key: "promo",
|
||||
label: "Промо-фрагмент",
|
||||
values: [
|
||||
{ label: "Скрывать", value: "hide" },
|
||||
{ label: "Показывать", value: "show" },
|
||||
],
|
||||
inputType: FilterInputs.Picker,
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
id: pluginId,
|
||||
name: sourceName,
|
||||
site: baseUrl,
|
||||
version: "1.0.0",
|
||||
lang: languages.Russian,
|
||||
icon: "src/ru/authortoday/icon.png",
|
||||
filters,
|
||||
popularNovels,
|
||||
parseNovelAndChapters,
|
||||
parseChapter,
|
||||
searchNovels,
|
||||
fetchImage: fetchFile,
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user