feat: Plugins (#465)

* update

* gitignore

* base file

* template

* json generator

* remove valid method

* Update README.md

README

* update template

* Update README.md

* update template

* not support async arrow function

* remove valid method

* basic plugin validation.

* Update README.md

* update template

* Update README.md

* add fetchFile lib. empy .language file

* comment fetch

* update

* comment fetch

* auto comment, update template, template.min

* Update README.md

* add option to test

* reset version

* Update README.md

* small fix for LightNovelReader

* comment fetch

* minor: LL date format

* refactor: rename project, remove html2text lib

* fix: error if there's no plugin changed

* implement cookies bypass

* update template.min.js

* add syosetu

* fix: get last file in case removing.
shorter id

* shoter native language name

* change app project name

* testing with UI would be less painful :)

* remove console.log

* Update README.md for UI testing

* fix Syosetu

* remove try catch

* add ranobehub

* add json for ranobehub

* wrong icon path :D

* fix ranobehub

* fix status ranobe

* add french

* fix css

* add chireads

* add indonesian

* add sakura novel

* add sakuranovel json

* add spanish

* add skynovels

* fix skynovels

* add agitoon

* add turkish

* add epiknovel

* add portuguese

* update template

* cheerio_space

* add novel Fullme

* minor

* lol, this source havent been finished before. cant help

* cant bypass this

* add hasutl

* novelasligera not working properly

* add novelpub, but no searching

* add jaomix

* fix jaomix

* add ranoberf

* add indowebnovel

* add novelringan

* add noveldeglace

* search not work for this

* add oasisTL, this should have better popularNovels

* add tunovelaligera

* this source need to fix search

* add bestlightnovel

* add comrade mao

* minor fix

* add divinedaolibrary

* add freewebnovel

* lol xD

* minor

* update json

* fix icon novelawuxia

* update site in for pluginItem

* some changes for more convenient

* remove try catch

* Update README.md

* remove

* Update README.md

* trying to use pre-commit

* update README

* feat: .env for repo config

* add foxaholic (#2)

* rebase fox

* fox officially 1.0.0

---------

Co-authored-by: K1ngfish3r <trulyihu@gmail.com>
This commit is contained in:
nyagami
2023-05-08 08:43:09 +07:00
committed by GitHub
parent d0f049c0b8
commit 8522c89195
70 changed files with 9958 additions and 2 deletions
View File
+217
View File
@@ -0,0 +1,217 @@
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 FilterInputs = require('@libs/filterInputs');
const pluginId = 'jaomix.ru';
const sourceName = 'Jaomix';
const baseUrl = 'https://jaomix.ru';
async function popularNovels (page, { showLatestNovels, filters }) {
let url = baseUrl + '/?searchrn&sortby=';
url += filters?.sort ? filters?.sort : (showLatestNovels ? 'upd' : 'count');
if (filters?.type?.length) {
url += filters.type.map(i => `&lang[]=${i}`).join('');
}
if (filters?.genres?.length) {
url += filters.genres.map(i => `&genre[]=${i}`).join('');
}
url += `&page=${page}`;
const result = await fetchApi(url);
let body = await result.text();
const loadedCheerio = cheerio.load(body);
let novels = [];
loadedCheerio('div[class="block-home"] > div[class="one"]').each(function () {
const novelName = loadedCheerio(this)
.find('div[class="img-home"] > a')
.attr('title');
const novelCover = loadedCheerio(this)
.find('div[class="img-home"] > a > img')
.attr('src')
.replace('-150x150', '');
const novelUrl = loadedCheerio(this)
.find('div[class="img-home"] > 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);
const body = await result.text();
const loadedCheerio = cheerio.load(body);
let novel = {
url: novelUrl,
};
novel.name = loadedCheerio('div[class="desc-book"] > h1').text().trim();
novel.cover = loadedCheerio('div[class="img-book"] > img').attr('src');
novel.summary = loadedCheerio('div[id="desc-tab"]').text().trim();
loadedCheerio('#info-book > p').each(function () {
let text = loadedCheerio(this).text().replace(/,/g, '').split(' ');
if (text[0] === 'Автор:') {
novel.author = text.splice(1).join(' ');
} else if (text[0] === 'Жанры:') {
novel.genres = text.splice(1).join(',');
} else if (text[0] === 'Статус:') {
novel.status = text.includes('продолжается')
? Status.Ongoing
: Status.Completed;
}
});
const chapters = [];
loadedCheerio('.download-chapter div.title').each(function () {
chapters.push({
name: loadedCheerio(this).find('a').attr('title'),
releaseTime: loadedCheerio(this).find('time').text(),
url: loadedCheerio(this).find('a').attr('href'),
});
});
novel.chapters = chapters.reverse();
return novel;
};
async function parseChapter (chapterUrl) {
const result = await fetchApi(chapterUrl);
const body = await result.text();
const loadedCheerio = cheerio.load(body);
loadedCheerio('div[class="adblock-service"]').remove();
const chapterText = loadedCheerio('div[class="entry-content"]').html();
return chapterText;
};
async function searchNovels (searchTerm) {
const url = `${baseUrl}/?searchrn=${searchTerm}&but=Поиск по названию&sortby=upd`;
const result = await fetchApi(url);
let body = await result.text();
const loadedCheerio = cheerio.load(body);
let novels = [];
loadedCheerio('div[class="block-home"] > div[class="one"]').each(function () {
const novelName = loadedCheerio(this)
.find('div[class="img-home"] > a')
.attr('title');
const novelCover = loadedCheerio(this)
.find('div[class="img-home"] > a > img')
.attr('src')
.replace('-150x150', '');
const novelUrl = loadedCheerio(this)
.find('div[class="img-home"] > a')
.attr('href');
const novel = {name: novelName, cover: novelCover, url: novelUrl };
novels.push(novel);
});
return novels;
};
const filters = [
{
key: 'sort',
label: 'Сортировка',
values: [
{ label: 'Имя', value: 'alphabet' },
{ label: 'Просмотры', value: 'count' },
{ label: 'Дате добавления', value: 'new' },
{ label: 'Дате обновления', value: 'upd' },
],
inputType: FilterInputs.Picker,
},
{
key: 'type',
label: 'Тип',
values: [
{ label: 'Английский', value: 'Английский' },
{ label: 'Китайский', value: 'Китайский' },
{ label: 'Корейский', value: 'Корейский' },
{ label: 'Японский', value: 'Японский' },
],
inputType: FilterInputs.Checkbox,
},
{
key: 'genres',
label: 'Жанры',
values: [
{ label: 'Adult', value: 'Adult' },
{ label: 'Ecchi', value: 'Ecchi' },
{ label: 'Josei', value: 'Josei' },
{ label: 'Lolicon', value: 'Lolicon' },
{ label: 'Mature', value: 'Mature' },
{ label: 'Sci-fi', value: 'Sci-fi' },
{ label: 'Shoujo', value: 'Shoujo' },
{ label: 'Wuxia', value: 'Wuxia' },
{ label: 'Xianxia', value: 'Xianxia' },
{ label: 'Xuanhuan', value: 'Xuanhuan' },
{ label: 'Yaoi', value: 'Yaoi' },
{ label: 'Боевые Искусства', value: 'Боевые Искусства' },
{ label: 'Виртуальный Мир', value: 'Виртуальный Мир' },
{ label: 'Гарем', value: 'Гарем' },
{ label: 'Детектив', value: 'Детектив' },
{ label: 'Драма', value: 'Драма' },
{ label: 'Игра', value: 'Игра' },
{ label: 'Истории из жизни', value: 'Истории из жизни' },
{ label: 'Исторический', value: 'Исторический' },
{ label: 'История', value: 'История' },
{ label: 'Комедия', value: 'Комедия' },
{ label: 'Меха', value: 'Меха' },
{ label: 'Мистика', value: 'Мистика' },
{ label: 'Научная Фантастика', value: 'Научная Фантастика' },
{ label: 'Повседневность', value: 'Повседневность' },
{ label: 'Постапокалипсис', value: 'Постапокалипсис' },
{ label: 'Приключения', value: 'Приключения' },
{ label: 'Психология', value: 'Психология' },
{ label: 'Романтика', value: 'Романтика' },
{ label: 'Сёнэн', value: 'Сёнэн' },
{ label: 'Сёнэн-ай', value: 'Сёнэн-ай' },
{ label: 'Сверхъестественное', value: 'Сверхъестественное' },
{ label: 'Спорт', value: 'Спорт' },
{ label: 'Сэйнэн', value: 'Сэйнэн' },
{ label: 'Сюаньхуа', value: 'Сюаньхуа' },
{ label: 'Трагедия', value: 'Трагедия' },
{ label: 'Триллер', value: 'Триллер' },
{ label: 'Фантастика', value: 'Фантастика' },
{ label: 'Фэнтези', value: 'Фэнтези' },
{ label: 'Хоррор', value: 'Хоррор' },
{ label: 'Школьная жизнь', value: 'Школьная жизнь' },
{ label: 'Шоунен', value: 'Шоунен' },
{ label: 'Экшн', value: 'Экшн' },
{ label: 'Этти', value: 'Этти' },
],
inputType: FilterInputs.Checkbox,
},
];
module.exports = {
id: pluginId,
name: sourceName,
site: baseUrl,
version: '1.0.0',
lang: languages.Russian,
icon: 'src/ru/jaomix/icon.png',
filters,
popularNovels,
parseNovelAndChapters,
parseChapter,
searchNovels,
fetchImage: fetchFile,
};
File diff suppressed because it is too large Load Diff
+147
View File
@@ -0,0 +1,147 @@
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 = "RNRF";
const sourceName = 'РанобэРФ';
const baseUrl = 'https://ранобэ.рф';
async function popularNovels (page, { showLatestNovels, filters }) {
let url = baseUrl + '/books?order=';
url += filters?.sort ? filters?.sort : (showLatestNovels ? 'lastPublishedChapter' : 'popular');
url += '&page=' + page;
const result = await fetchApi(url);
const body = await result.text();
const loadedCheerio = cheerio.load(body);
let json = loadedCheerio('#__NEXT_DATA__').html();
json = JSON.parse(json);
let novels = [];
json.props.pageProps.totalData.items.forEach(item => {
const novelName = item.title;
const novelUrl = baseUrl + '/' + item.slug;
const novelCover = item?.verticalImage?.url
? baseUrl + item.verticalImage.url
: defaultCoverUri;
novels.push({ name: novelName, cover: novelCover, url: novelUrl });
});
return novels;
};
async function parseNovelAndChapters (novelUrl) {
const result = await fetchApi(novelUrl);
const body = await result.text();
const loadedCheerio = cheerio.load(body);
let json = loadedCheerio('#__NEXT_DATA__').html();
json = JSON.parse(json);
let novel = {
url: novelUrl,
name: json.props.pageProps.book.title,
cover: json.props.pageProps.book?.verticalImage?.url
? baseUrl + json.props.pageProps.book.verticalImage.url
: defaultCoverUri,
summary: json.props.pageProps.book.description,
author: json.props.pageProps.book?.author || '',
genres: json.props.pageProps.book.genres.map(item => item.title).join(','),
status: json.props.pageProps.book.additionalInfo.includes('Активен')
? Status.Ongoing
: Status.Completed,
};
let chapters = [];
json.props.pageProps.book.chapters.forEach(item => {
const chapterName = item.title;
const releaseDate = dayjs(item.publishedAt).format('LLL');
const chapterUrl = baseUrl + item.url;
if (!item.isDonate || item.isUserPaid) {
chapters.push({ name: chapterName, releaseTime: releaseDate, url: chapterUrl });
}
});
novel.chapters = chapters.reverse();
return novel;
};
async function parseChapter (chapterUrl) {
const result = await fetchApi(chapterUrl);
const body = await result.text();
const loadedCheerio = cheerio.load(body);
let json = loadedCheerio('#__NEXT_DATA__').html();
json = JSON.parse(json);
let temp = cheerio.load(json.props.pageProps.chapter.content.text);
temp('img').each(function () {
if (!loadedCheerio(this).attr('src')?.startsWith('http')) {
let src = loadedCheerio(this).attr('src');
loadedCheerio(this).attr('src', baseUrl + src);
}
});
const chapterText = temp.html();
return chapterText;
};
async function searchNovels (searchTerm) {
const url = `${baseUrl}/v3/books?filter[or][0][title][like]=${searchTerm}&filter[or][1][titleEn][like]=${searchTerm}&filter[or][2][fullTitle][like]=${searchTerm}&filter[status][]=active&filter[status][]=abandoned&filter[status][]=completed&expand=verticalImage`;
const result = await fetchApi(url);
const body = await result.json();
let novels = [];
body.items.forEach(item => {
const novelName = item.title;
const novelUrl = baseUrl + '/' + item.slug;
const novelCover = item?.verticalImage?.url
? baseUrl + item.verticalImage.url
: defaultCoverUri;
novels.push({ name: novelName, cover: novelCover, url: novelUrl });
});
return novels;
};
const filters = [
{
key: 'sort',
label: 'Сортировка',
values: [
{ label: 'Рейтинг', value: 'popular' },
{ label: 'Дате добавления', value: 'new' },
{ label: 'Дате обновления', value: 'lastPublishedChapter' },
{ label: 'Законченные', value: 'completed' },
],
inputType: FilterInputs.Picker,
},
];
module.exports = {
id: pluginId,
name: sourceName,
site: baseUrl,
version: '1.0.0',
lang: languages.Russian,
icon: 'src/ru/ranoberf/icon.png',
filters,
popularNovels,
parseNovelAndChapters,
parseChapter,
searchNovels,
fetchImage: fetchFile,
};