e602df44c8
* 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>
130 lines
3.7 KiB
TypeScript
130 lines
3.7 KiB
TypeScript
import { fetchApi, fetchFile } from "@libs/fetch";
|
|
import { Chapter, Novel, Plugin } from "@typings/plugin";
|
|
|
|
export const id = "skynovels.net";
|
|
export const name = "SkyNovels";
|
|
export const site = "https://www.skynovels.net/";
|
|
export const version = "1.0.0";
|
|
export const icon = "src/es/skynovels/icon.png";
|
|
|
|
const baseUrl = site;
|
|
|
|
export const popularNovels: Plugin.popularNovels = async function (page) {
|
|
const url = "https://api.skynovels.net/api/novels?&q";
|
|
|
|
const result = await fetchApi(url);
|
|
const body = await result.json();
|
|
|
|
const novels: Novel.Item[] = [];
|
|
|
|
body.novels.map((res) => {
|
|
const novelName = res.nvl_title;
|
|
const novelCover =
|
|
"https://api.skynovels.net/api/get-image/" +
|
|
res.image +
|
|
"/novels/false";
|
|
const novelUrl =
|
|
baseUrl + "novelas/" + res.id + "/" + res.nvl_name + "/";
|
|
|
|
const novel = { name: novelName, url: novelUrl, cover: novelCover };
|
|
|
|
novels.push(novel);
|
|
});
|
|
|
|
return novels;
|
|
};
|
|
|
|
export const parseNovelAndChapters: Plugin.parseNovelAndChapters =
|
|
async function (novUrl) {
|
|
let novelId = novUrl.substring().split("/")[4];
|
|
const url =
|
|
"https://api.skynovels.net/api/novel/" + novelId + "/reading?&q";
|
|
|
|
const result = await fetchApi(url);
|
|
const body = await result.json();
|
|
|
|
const item = body.novel[0];
|
|
|
|
let novel: Novel.instance = { url: novUrl };
|
|
|
|
novel.name = item.nvl_title;
|
|
|
|
novel.cover =
|
|
"https://api.skynovels.net/api/get-image/" +
|
|
item.image +
|
|
"/novels/false";
|
|
|
|
let genres: string[] = [];
|
|
item.genres.map((genre) => genres.push(genre.genre_name));
|
|
novel.genres = genres.join(",");
|
|
novel.author = item.nvl_writer;
|
|
novel.summary = item.nvl_content;
|
|
novel.status = item.nvl_status;
|
|
|
|
let novelChapters: Chapter.Item[] = [];
|
|
|
|
item.volumes.map((volume) => {
|
|
volume.chapters.map((chapter) => {
|
|
const chapterName = chapter.chp_index_title;
|
|
const releaseDate = new Date(chapter.createdAt).toDateString();
|
|
const chapterUrl = novUrl + chapter.id + "/" + chapter.chp_name;
|
|
|
|
const chap = {
|
|
name: chapterName,
|
|
releaseTime: releaseDate,
|
|
url: chapterUrl,
|
|
};
|
|
|
|
novelChapters.push(chap);
|
|
});
|
|
});
|
|
|
|
novel.chapters = novelChapters;
|
|
|
|
return novel;
|
|
};
|
|
|
|
export const parseChapter: Plugin.parseChapter = async function (chapUrl) {
|
|
let chapterId = chapUrl.split("/")[6];
|
|
const url = `https://api.skynovels.net/api/novel-chapter/${chapterId}`;
|
|
|
|
const result = await fetchApi(url);
|
|
const body = await result.json();
|
|
|
|
const item = body.chapter[0];
|
|
|
|
let chapterText = item.chp_content;
|
|
|
|
return chapterText;
|
|
};
|
|
|
|
export const searchNovels: Plugin.searchNovels = async function (searchTerm) {
|
|
searchTerm = searchTerm.toLowerCase();
|
|
const url = "https://api.skynovels.net/api/novels?&q";
|
|
|
|
const result = await fetchApi(url);
|
|
const body = await result.json();
|
|
|
|
let results = body.novels.filter((novel) =>
|
|
novel.nvl_title.toLowerCase().includes(searchTerm)
|
|
);
|
|
|
|
const novels: Novel.Item[] = [];
|
|
|
|
results.map((res) => {
|
|
const novelName = res.nvl_title;
|
|
const novelCover =
|
|
"https://api.skynovels.net/api/get-image/" +
|
|
res.image +
|
|
"/novels/false";
|
|
const novelUrl =
|
|
baseUrl + "novelas/" + res.id + "/" + res.nvl_name + "/";
|
|
|
|
const novel = { name: novelName, url: novelUrl, cover: novelCover };
|
|
|
|
novels.push(novel);
|
|
});
|
|
|
|
return novels;
|
|
};
|