Beta phase (#801)
* beta host * Refactor: url -> path (#757) * refactor: url -> path * clean up * fix: json branch * PagePlugin (#769) * paginated novel support * fix: truyenfull * fix: tunovel, remove pageList * parsePage support for webtest (#773) * add parsePage api * add parsePage UI * add totalPages * (FR src) Beta plugin & Added filters (#775) * noveldeglace: - added filters - added latest - defaultCover fallback - change id to noveldeglace.com - added complementary infos in summary - added cover artist - chapters are now parts - show volume number for multi volume novels - better search - fix search page number - refactored for plugin beta - releaseDate as Date.toString() - separted parseNovels - separated getCheerio - loadedCheerio => $ for shorter lines & simpler test on web * chireads: - fix different parsing for mobile version - added filters - added author - added status - added released date - refactored for plugin beta - separted parseNovels - separated getCheerio - loadedCheerio => $ for shorter lines & simpler test on web * wpmangastream => lightnovelwp rework & new sources (#776) * Added sources: - Knoxt (EN) - Baca Light Novel (ID) - AllNovelRead (ES) - DaoTranslate (EN) - جنة الروايات (AR) - Universal Novel (EN) - NovelTR (TR) old sources auto-generated: - GenesisTls (EN) - NobleMTL (EN) wpmangastream => lightnovelwp: - added doc - added filters in a separte file - semi-automatic filter generator - made it compatible with version 1.0.X and 1.1.X versions of the theme - loadedCheerio => $ - icons in "/icons/lightnovel/id.png" - code cleanup * removed auto-implemented sources * Added README.md to lightnovelwp * removed ai generated text for kolnovel * added novelsknight * added centralNovel * pandamtl accual name * adding folder plugin/arabic * Fix: Vietnamese plugins (#777) * fix: lightnovelvn * add nettruyen * add truyenchu * fix: truyenconect * Fix: Migrate plugins (#771) * Add novel.ovh (#756) * fix * test * fix * date fix + master merge (#761) * date fix * Added Brazilian Portuguese E-Novel (#758) * fixed single digit dates (#767) Co-authored-by: NaddH1 <naderhorani@hotmail.com> * fix * test * fix order * Update renovels.ts * require_chapters * Delete plugins/english/genesistl.broken.ts * Update novelTL.ts --------- Co-authored-by: NaddH1 <naderhorani@hotmail.com> * (src update) ENG (#772) * allnovelfull * bestlightnovel * divinedaolibrary * earlynovel * lightnovelpub * L * M * novelbin * novelfull * novelbuddy * N S * novel updates * async sleep * rename file * pagePlugin * Feat: minify js dir (#781) * Multisrc: HotNovelPub (#784) * HotNovelPub * fix search * Squashed commit of the following: commit 3b759c68eddc06c0adfb959f775de069a85adca7 Author: nyagami <hoangquan05112002@gmail.com> Date: Sat Feb 17 20:33:47 2024 +0700 Feat: minify js dir (#781) * jsmin changed to terser * test * why I did it. * test * Update ranobelib.ts * fix page * Update ranobelib.ts * updated modules * Update terser.json Co-authored-by: nyagami <hoangquan05112002@gmail.com> * Update scripts/multisrc/hotnovelpub/template.ts Co-authored-by: nyagami <hoangquan05112002@gmail.com> * terser api --------- Co-authored-by: nyagami <hoangquan05112002@gmail.com> * Added sources & fix sources (#787) * lightnovelwp: - fix author name - added more localisation of strings - README typo - error on !r.ok new message * noveldeglace: - fix chapterNumber for parts - better dates - better search * Added sources: - White Moonlight Novels (EN) - System Translation (EN) * Resized centralnovel.png * Add Faqwiki.us source (#792) * Add Faqwiki.us source (beta branch) * Fix Path, Fix Chapter Parsing, Fix Novel Title * search novel path fix * fix chapter parsing. some chapter in this site store their whole text in 1-4 <p>, * Add WTR-LAB Source (#797) * Add WTR-LAB Source (Beta Branch) * Add other language from WTR-LAB source * change lang to sourceLang * remove id es tr lang from WTR-LAB * Update plugins/english/wtrlab.ts agree Co-authored-by: nyagami <hoangquan05112002@gmail.com> * Update plugins/english/wtrlab.ts agree Co-authored-by: nyagami <hoangquan05112002@gmail.com> --------- Co-authored-by: nyagami <hoangquan05112002@gmail.com> * revert: scripts to master --------- Co-authored-by: Justin COLLON <48163201+error7404@users.noreply.github.com> Co-authored-by: Rider21 <58046032+Rider21@users.noreply.github.com> Co-authored-by: NaddH1 <naderhorani@hotmail.com> Co-authored-by: K1ngfish3r <trulyihu@gmail.com> Co-authored-by: bregassa <bregas.sat1@gmail.com>
This commit is contained in:
+28
-22
@@ -14,7 +14,10 @@ class freedlit implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/get-books/all/list/" + page + "?sort=";
|
||||
url += showLatestNovels ? "recent" : filters?.sort?.value || "popular";
|
||||
@@ -38,27 +41,30 @@ class freedlit implements Plugin.PluginBase {
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio("#bookListBlock > div > div").each(function () {
|
||||
const name = loadedCheerio(this).find("div > h4 > a").text()?.trim();
|
||||
const cover = loadedCheerio(this)
|
||||
loadedCheerio("#bookListBlock > div > div").each((index, element) => {
|
||||
const name = loadedCheerio(element).find("div > h4 > a").text()?.trim();
|
||||
const cover = loadedCheerio(element)
|
||||
.find("div > a > img")
|
||||
.attr("src")
|
||||
?.trim();
|
||||
const url = loadedCheerio(this).find("div > h4 > a").attr("href")?.trim();
|
||||
const url = loadedCheerio(element)
|
||||
.find("div > h4 > a")
|
||||
.attr("href")
|
||||
?.trim();
|
||||
if (!name || !url) return;
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
novels.push({ name, cover, path: url.replace(this.site, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(this.site + novelPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: loadedCheerio(".book-info h4").text(),
|
||||
cover: loadedCheerio(".book-cover > div > img").attr("src")?.trim(),
|
||||
summary: loadedCheerio("#nav-home").text()?.trim(),
|
||||
@@ -77,11 +83,11 @@ class freedlit implements Plugin.PluginBase {
|
||||
if (!name || !url) return;
|
||||
|
||||
const releaseDate = loadedCheerio(element).find('span[class="date"]').text();
|
||||
chapters.push({
|
||||
name,
|
||||
url,
|
||||
releaseTime: this.parseDate(releaseDate),
|
||||
chapterNumber: chapterIndex + 1
|
||||
chapters.push({
|
||||
name,
|
||||
path: url.replace(this.site, ""),
|
||||
releaseTime: this.parseDate(releaseDate),
|
||||
chapterNumber: chapterIndex + 1,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,8 +95,8 @@ class freedlit implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const body = await fetchApi(this.site + chapterPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio("div.mobile-block").remove();
|
||||
@@ -101,18 +107,18 @@ class freedlit implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/search?query=${searchTerm}&type=all`;
|
||||
const url = this.site + "/search?query=" + searchTerm + "&type=all";
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio("#bookListBlock > div").each(function () {
|
||||
const name = loadedCheerio(this).find("h4 > a").text()?.trim();
|
||||
const cover = loadedCheerio(this).find("a > img").attr("src")?.trim();
|
||||
const url = loadedCheerio(this).find("h4 > a").attr("href")?.trim();
|
||||
loadedCheerio("#bookListBlock > div").each((index, element) => {
|
||||
const name = loadedCheerio(element).find("h4 > a").text()?.trim();
|
||||
const cover = loadedCheerio(element).find("a > img").attr("src")?.trim();
|
||||
const url = loadedCheerio(element).find("h4 > a").attr("href")?.trim();
|
||||
if (!name || !url) return;
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
novels.push({ name, cover, path: url.replace(this.site, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
|
||||
@@ -53,14 +53,15 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
cover: novel.coverUrl
|
||||
? "https://cm.author.today/content/" + novel.coverUrl
|
||||
: defaultCover,
|
||||
url: this.site + "/work/" + novel.id,
|
||||
path: "/work/" + novel.id,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const workID = novelUrl.split("/")[4];
|
||||
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const workID = novelPath.split("/")[2];
|
||||
const result = await fetchApi(`${apiUrl}v1/work/${workID}/details`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
@@ -69,7 +70,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
|
||||
const book = (await result.json()) as responseBook;
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: book.title,
|
||||
cover: book.coverUrl ? book.coverUrl.split("?")[0] : defaultCover,
|
||||
genres: book.tags?.join(", "),
|
||||
@@ -84,10 +85,13 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
status: book.isFinished ? NovelStatus.Completed : NovelStatus.Ongoing,
|
||||
};
|
||||
|
||||
if (book.annotation) novel.summary += book.annotation + "\n";
|
||||
if (book.authorNotes) novel.summary += "Примечания автора:\n" + book.authorNotes;
|
||||
if (book.annotation) {
|
||||
novel.summary += book.annotation + "\n";
|
||||
}
|
||||
if (book.authorNotes) {
|
||||
novel.summary += "Примечания автора:\n" + book.authorNotes;
|
||||
}
|
||||
|
||||
// all chapters
|
||||
const chaptersRaw = await fetchApi(`${apiUrl}v1/work/${workID}/content`, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
@@ -96,12 +100,15 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
|
||||
const chaptersJSON = (await chaptersRaw.json()) as ChaptersEntity[];
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
chaptersJSON.forEach((chapter, chapterIndex) => {
|
||||
if (chapter.isAvailable && !chapter.isDraft) {
|
||||
chapters.push({
|
||||
name: chapter.title || 'Глава ' + (chapterIndex + 1),
|
||||
url: `${apiUrl}v1/work/${workID}/chapter/${chapter.id}/text`,
|
||||
releaseTime: dayjs(chapter.publishTime || chapter.lastModificationTime).format("LLL"),
|
||||
name: chapter.title || "Глава " + (chapterIndex + 1),
|
||||
path: `v1/work/${workID}/chapter/${chapter.id}/text`,
|
||||
releaseTime: dayjs(
|
||||
chapter.publishTime || chapter.lastModificationTime,
|
||||
).format("LLL"),
|
||||
chapterNumber: (chapter.sortOrder || chapterIndex) + 1,
|
||||
});
|
||||
}
|
||||
@@ -111,8 +118,8 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const result = await fetchApi(chapterUrl, {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(apiUrl + chapterPath, {
|
||||
headers: {
|
||||
Authorization: token,
|
||||
},
|
||||
@@ -159,15 +166,14 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
.text()
|
||||
.trim();
|
||||
let cover = loadedCheerio(element).find("img").attr("src");
|
||||
const url = loadedCheerio(element)
|
||||
const path = loadedCheerio(element)
|
||||
.find('div[class="book-title"] a')
|
||||
.attr("href")
|
||||
?.split("/")?.[2];
|
||||
.attr("href");
|
||||
|
||||
cover = cover ? cover.split("?")[0] : defaultCover;
|
||||
|
||||
if (!url) return;
|
||||
novels.push({ name, cover, url: this.site + "/work/" + url });
|
||||
if (!path) return;
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
@@ -193,7 +199,7 @@ class AuthorToday implements Plugin.PluginBase {
|
||||
label: "Жанры",
|
||||
value: "",
|
||||
options: [
|
||||
{ label: "Все", value:"" },
|
||||
{ label: "Все", value: "" },
|
||||
{ label: "Альтернативная история", value: "sf-history" },
|
||||
{ label: "Антиутопия", value: "dystopia" },
|
||||
{ label: "Бизнес-литература", value: "biznes-literatura" },
|
||||
|
||||
@@ -14,10 +14,15 @@ class Bookriver implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + `/genre?page=${pageNo}&perPage=24&sortingType=`;
|
||||
url += showLatestNovels ? "last-update" : filters?.sort?.value || "bestseller";
|
||||
let url = this.site + "/genre?page=" + pageNo + "&perPage=24&sortingType=";
|
||||
url += showLatestNovels
|
||||
? "last-update"
|
||||
: filters?.sort?.value || "bestseller";
|
||||
|
||||
if (filters?.genres?.value?.length) {
|
||||
url += "&g=" + filters.genres.value.join(",");
|
||||
@@ -34,15 +39,15 @@ class Bookriver implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.name,
|
||||
cover: novel.coverImages[0].url,
|
||||
url: this.site + "/book/" + novel.slug,
|
||||
path: "/book/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
}
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(novelUrl).then((res) => res.text());
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(this.site + novelPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
|
||||
const jsonRaw = loadedCheerio("#__NEXT_DATA__").html();
|
||||
@@ -50,8 +55,8 @@ class Bookriver implements Plugin.PluginBase {
|
||||
const book = json.props.pageProps.state.book?.bookPage;
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: book?.name,
|
||||
path: novelPath,
|
||||
name: book?.name || "",
|
||||
cover: book?.coverImages[0].url,
|
||||
summary: book?.annotation,
|
||||
author: book?.author?.name,
|
||||
@@ -67,7 +72,7 @@ class Bookriver implements Plugin.PluginBase {
|
||||
if (chapter.available) {
|
||||
chapters.push({
|
||||
name: chapter.name,
|
||||
url: this.site + "/reader/" + book?.slug + "/" + chapter.chapterId,
|
||||
path: "/reader/" + book?.slug + "/" + chapter.chapterId,
|
||||
releaseTime: dayjs(
|
||||
chapter.firstPublishedAt || chapter.createdAt || undefined,
|
||||
).format("LLL"),
|
||||
@@ -79,9 +84,9 @@ class Bookriver implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = "https://api.bookriver.ru/api/v1/books/chapter/text/";
|
||||
const result = await fetchApi(url + chapterUrl.split("/").pop());
|
||||
const result = await fetchApi(url + chapterPath.split("/").pop());
|
||||
const json = (await result.json()) as responseChapter;
|
||||
|
||||
let chapterText = json.data.content || "Конец произведения";
|
||||
@@ -96,7 +101,9 @@ class Bookriver implements Plugin.PluginBase {
|
||||
searchTerm: string,
|
||||
pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `https://api.bookriver.ru/api/v1/search/autocomplete?keyword=${searchTerm}&page=${pageNo}&perPage=10`;
|
||||
const url =
|
||||
"https://api.bookriver.ru/api/v1/search/autocomplete?keyword=" + searchTerm +
|
||||
"&page=" + pageNo + "&perPage=10";
|
||||
const result = await fetchApi(url);
|
||||
const json = (await result.json()) as responseSearch;
|
||||
|
||||
@@ -105,12 +112,13 @@ class Bookriver implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.name,
|
||||
cover: novel.coverImages[0].url,
|
||||
url: this.site + "/book/" + novel.slug,
|
||||
path: "/book/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
|
||||
filters = {
|
||||
|
||||
+18
-20
@@ -41,25 +41,24 @@ class ficbook implements Plugin.PluginBase {
|
||||
: defaultCover;
|
||||
if (!name || !url) return;
|
||||
|
||||
novels.push({ name, cover, url: this.site + url.replace(/\?.*/g, "") });
|
||||
novels.push({ name, cover, path: url.replace(/\?.*/g, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(novelUrl).then((res) => res.text());
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(this.site + novelPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: (
|
||||
loadedCheerio('h1[itemprop="headline"]').text() ||
|
||||
loadedCheerio('h1[itemprop="name"]').text() ||
|
||||
""
|
||||
).trim(),
|
||||
};
|
||||
|
||||
novel.name = (
|
||||
loadedCheerio('h1[itemprop="headline"]').text() ||
|
||||
loadedCheerio('h1[itemprop="name"]').text()
|
||||
).trim();
|
||||
|
||||
novel.cover = loadedCheerio('meta[property="og:image"]').attr("content");
|
||||
novel.summary = loadedCheerio('div[itemprop="description"]').text().trim();
|
||||
novel.author = loadedCheerio('a[itemprop="author"]').text();
|
||||
@@ -91,7 +90,7 @@ class ficbook implements Plugin.PluginBase {
|
||||
const name = loadedCheerio(".title-area > h2").text();
|
||||
const releaseTime = loadedCheerio(".part-date > span").attr("title");
|
||||
|
||||
if (name) chapters.push({ name, url: novelUrl, releaseTime });
|
||||
if (name) chapters.push({ name, path: novelPath, releaseTime });
|
||||
} else {
|
||||
loadedCheerio("li.part").each((chapterIndex, element) => {
|
||||
const name = loadedCheerio(element).find("h3").text();
|
||||
@@ -99,22 +98,21 @@ class ficbook implements Plugin.PluginBase {
|
||||
if (!name || !url) return;
|
||||
|
||||
const releaseTime = loadedCheerio(element).find("div > span").attr("title");
|
||||
chapters.push({
|
||||
name,
|
||||
url: this.site + url,
|
||||
releaseTime,
|
||||
chapters.push({
|
||||
name,
|
||||
path: url.replace(this.site, ""),
|
||||
releaseTime,
|
||||
chapterNumber: chapterIndex + 1,
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const result = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(this.site + chapterPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(result);
|
||||
let chapterText = "";
|
||||
|
||||
@@ -154,12 +152,12 @@ class ficbook implements Plugin.PluginBase {
|
||||
|
||||
json.data?.data?.forEach((novel) => {
|
||||
const name = novel.title.trim();
|
||||
const url = this.site + "/readfic/" + novel.slug;
|
||||
const path = "/readfic/" + novel.slug;
|
||||
const cover = novel.cover
|
||||
? "https://images.ficbook.net/fanfic-covers/" + novel.cover
|
||||
: defaultCover;
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
novels.push({ name, cover, path });
|
||||
});
|
||||
|
||||
return novels;
|
||||
|
||||
+31
-28
@@ -14,7 +14,10 @@ class Jaomix implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/?searchrn";
|
||||
|
||||
@@ -45,34 +48,33 @@ class Jaomix implements Plugin.PluginBase {
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio('div[class="block-home"] > div[class="one"]').each(
|
||||
function () {
|
||||
const name = loadedCheerio(this)
|
||||
loadedCheerio('div[class="block-home"] > div[class="one"]')
|
||||
.each((index, element) => {
|
||||
const name = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a')
|
||||
.attr("title");
|
||||
const cover = loadedCheerio(this)
|
||||
const cover = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a > img')
|
||||
.attr("src")
|
||||
?.replace("-150x150", "");
|
||||
const url = loadedCheerio(this)
|
||||
const url = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a')
|
||||
.attr("href");
|
||||
|
||||
if (!name || !url) return;
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
},
|
||||
);
|
||||
novels.push({ name, cover, path: url.replace(this.site, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(this.site + novelPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: loadedCheerio('div[class="desc-book"] > h1').text().trim(),
|
||||
cover: loadedCheerio('div[class="img-book"] > img').attr("src"),
|
||||
summary: loadedCheerio('div[id="desc-tab"]').text().trim(),
|
||||
@@ -100,11 +102,11 @@ class Jaomix implements Plugin.PluginBase {
|
||||
if (!name || !url) return;
|
||||
|
||||
const releaseDate = loadedCheerio(element).find("time").text();
|
||||
chapters.push({
|
||||
name,
|
||||
url,
|
||||
releaseTime: this.parseDate(releaseDate),
|
||||
chapterNumber: totalChapters - chapterIndex
|
||||
chapters.push({
|
||||
name,
|
||||
path: url.replace(this.site, ""),
|
||||
releaseTime: this.parseDate(releaseDate),
|
||||
chapterNumber: totalChapters - chapterIndex,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -112,8 +114,8 @@ class Jaomix implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const body = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const body = await fetchApi(this.site + chapterPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
loadedCheerio('div[class="adblock-service"]').remove();
|
||||
@@ -126,29 +128,30 @@ class Jaomix implements Plugin.PluginBase {
|
||||
searchTerm: string,
|
||||
pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/?searchrn=${searchTerm}&but=Поиск по названию&sortby=upd&gpage=${pageNo}`;
|
||||
const url =
|
||||
this.site + "/?searchrn=" + searchTerm +
|
||||
"&but=Поиск по названию&sortby=upd&gpage=" + pageNo;
|
||||
const body = await fetchApi(url).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio('div[class="block-home"] > div[class="one"]').each(
|
||||
function () {
|
||||
const name = loadedCheerio(this)
|
||||
loadedCheerio('div[class="block-home"] > div[class="one"]')
|
||||
.each((index, element) => {
|
||||
const name = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a')
|
||||
.attr("title");
|
||||
const cover = loadedCheerio(this)
|
||||
const cover = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a > img')
|
||||
.attr("src")
|
||||
?.replace("-150x150", "");
|
||||
const url = loadedCheerio(this)
|
||||
const url = loadedCheerio(element)
|
||||
.find('div[class="img-home"] > a')
|
||||
.attr("href");
|
||||
|
||||
if (!name || !url) return;
|
||||
|
||||
novels.push({ name, cover, url });
|
||||
},
|
||||
);
|
||||
novels.push({ name, cover, path: url.replace(this.site, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
+12
-12
@@ -9,7 +9,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
name = "НовелОВХ";
|
||||
site = "https://novel.ovh";
|
||||
version = "1.0.0";
|
||||
icon = "src/ru/novelOvh/icon.png";
|
||||
icon = "src/ru/novelovh/icon.png";
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
@@ -27,21 +27,21 @@ class novelOvh implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.name.ru,
|
||||
cover: novel.poster,
|
||||
url: this.site + "/novel/" + novel.slug,
|
||||
path: "/novel/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(
|
||||
novelUrl + "?_data=routes/reader/book/$slug/index",
|
||||
this.site + novelPath + "?_data=routes/reader/book/$slug/index",
|
||||
);
|
||||
const json = (await result.json()) as responseNovel;
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: json.book.name.ru,
|
||||
cover: json.book.poster,
|
||||
genres: json.book.labels?.map?.((label) => label.name).join(","),
|
||||
@@ -67,10 +67,10 @@ class novelOvh implements Plugin.PluginBase {
|
||||
chapters.push({
|
||||
name:
|
||||
chapter.title ||
|
||||
"Том " + (chapter.volume || 0) + " " +
|
||||
(chapter.name || "Глава " +
|
||||
(chapter.number || json.chapters.length - chapterIndex)),
|
||||
url: novelUrl + "/" + chapter.id + "/0",
|
||||
"Том " + (chapter.volume || 0) + " " +
|
||||
(chapter.name || "Глава " +
|
||||
(chapter.number || json.chapters.length - chapterIndex)),
|
||||
path: novelPath + "/" + chapter.id + "/0",
|
||||
releaseTime: dayjs(chapter.createdAt).format("LLL"),
|
||||
chapterNumber: json.chapters.length - chapterIndex,
|
||||
}),
|
||||
@@ -80,9 +80,9 @@ class novelOvh implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(
|
||||
"https://api.novel.ovh/v2/chapters/" + chapterUrl.split("/")[5],
|
||||
"https://api.novel.ovh/v2/chapters/" + chapterPath.split("/")[3],
|
||||
);
|
||||
const book = (await result.json()) as responseChapter;
|
||||
const image = Object.fromEntries(
|
||||
@@ -106,7 +106,7 @@ class novelOvh implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.name.ru,
|
||||
cover: novel.poster,
|
||||
url: this.site + "/novel/" + novel.slug,
|
||||
path: "/novel/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
+22
-19
@@ -6,6 +6,13 @@ import { NovelStatus } from "@libs/novelStatus";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const statusKey: { [key: string]: string } = {
|
||||
"active": NovelStatus.Ongoing,
|
||||
"completed": NovelStatus.Completed,
|
||||
"freezed": NovelStatus.OnHiatus,
|
||||
"unknown": NovelStatus.Unknown,
|
||||
};
|
||||
|
||||
class TL implements Plugin.PluginBase {
|
||||
id = "TL";
|
||||
name = "NovelTL";
|
||||
@@ -24,9 +31,8 @@ class TL implements Plugin.PluginBase {
|
||||
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
referrer: this.site,
|
||||
Referer: this.site,
|
||||
body: JSON.stringify({
|
||||
operationName: "Projects",
|
||||
query:
|
||||
"query Projects($hostname:String! $filter:SearchFilter $page:Int $limit:Int){projects(section:{fullUrl:$hostname}filter:$filter page:{pageSize:$limit,pageNumber:$page}){content{title fullUrl covers{url}}}}",
|
||||
variables: {
|
||||
@@ -47,7 +53,7 @@ class TL implements Plugin.PluginBase {
|
||||
json.data?.projects?.content?.forEach((novel) =>
|
||||
novels.push({
|
||||
name: novel.title,
|
||||
url: "https://" + novel.fullUrl,
|
||||
path: novel.fullUrl,
|
||||
cover: novel?.covers?.[0]?.url
|
||||
? this.site + novel.covers[0].url
|
||||
: defaultCover,
|
||||
@@ -57,7 +63,7 @@ class TL implements Plugin.PluginBase {
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(this.site + "/api/site/v2/graphql", {
|
||||
method: "post",
|
||||
headers: {
|
||||
@@ -65,28 +71,25 @@ class TL implements Plugin.PluginBase {
|
||||
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
referrer: this.site,
|
||||
Referer: this.site,
|
||||
body: JSON.stringify({
|
||||
operationName: "Book",
|
||||
query:
|
||||
'query Book($url:String){project(project:{fullUrl:$url}){title translationStatus fullUrl covers{url}persons(langs:["ru","en","*"],roles:["author","illustrator"]){role name{firstName lastName}}genres{nameRu nameEng}tags{nameRu nameEng}annotation{text}subprojects{content{title volumes{content{shortName chapters{title publishDate fullUrl published}}}}}}}',
|
||||
variables: {
|
||||
url: novelUrl,
|
||||
url: novelPath,
|
||||
},
|
||||
}),
|
||||
});
|
||||
const json = (await result.json()) as response;
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: json.data.project?.title,
|
||||
path: novelPath,
|
||||
name: json.data.project?.title || "",
|
||||
cover: json.data.project?.covers?.[0]?.url
|
||||
? this.site + json.data.project.covers[0].url
|
||||
: defaultCover,
|
||||
summary: json.data.project?.annotation?.text,
|
||||
status:
|
||||
json.data.project?.translationStatus === "active"
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed,
|
||||
statusKey[json.data.project?.translationStatus || "unknown"] || NovelStatus.Unknown,
|
||||
};
|
||||
|
||||
const genres = [json.data.project?.tags, json.data.project?.genres]
|
||||
@@ -119,9 +122,10 @@ class TL implements Plugin.PluginBase {
|
||||
name:
|
||||
(volume.shortName || "Том " + (volumeIndex + 1)) + " " +
|
||||
(chapter.title || "Глава " + (chapterIndex + 1)),
|
||||
url: "https://" + chapter.fullUrl,
|
||||
path: chapter.fullUrl,
|
||||
releaseTime: dayjs(chapter.publishDate).format("LLL"),
|
||||
chapterNumber: chapters.length + 1,
|
||||
page: work.title || "Основная серия",
|
||||
});
|
||||
}
|
||||
}),
|
||||
@@ -132,7 +136,7 @@ class TL implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(this.site + "/api/site/v2/graphql", {
|
||||
method: "post",
|
||||
headers: {
|
||||
@@ -140,12 +144,12 @@ class TL implements Plugin.PluginBase {
|
||||
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
referrer: this.site,
|
||||
Referer: this.site,
|
||||
body: JSON.stringify({
|
||||
query:
|
||||
"query($url:String){chapter(chapter:{fullUrl:$url}){text{text}}}",
|
||||
variables: {
|
||||
url: decodeURI(chapterUrl),
|
||||
url: decodeURI(chapterPath),
|
||||
},
|
||||
}),
|
||||
});
|
||||
@@ -177,9 +181,8 @@ class TL implements Plugin.PluginBase {
|
||||
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
referrer: this.site,
|
||||
Referer: this.site,
|
||||
body: JSON.stringify({
|
||||
operationName: "Projects",
|
||||
query:
|
||||
"query Projects($hostname:String! $filter:SearchFilter $page:Int $limit:Int){projects(section:{fullUrl:$hostname}filter:$filter page:{pageSize:$limit,pageNumber:$page}){content{title fullUrl covers{url}}}}",
|
||||
variables: {
|
||||
@@ -198,7 +201,7 @@ class TL implements Plugin.PluginBase {
|
||||
json?.data?.projects?.content?.forEach((novel) =>
|
||||
novels.push({
|
||||
name: novel.title,
|
||||
url: "https://" + novel.fullUrl,
|
||||
path: novel.fullUrl,
|
||||
cover: novel?.covers?.[0]?.url
|
||||
? this.site + novel.covers[0].url
|
||||
: defaultCover,
|
||||
|
||||
@@ -5,6 +5,12 @@ import { NovelStatus } from "@libs/novelStatus";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const statusKey: { [key: number]: string } = {
|
||||
1: NovelStatus.Ongoing,
|
||||
2: NovelStatus.Completed,
|
||||
3: NovelStatus.OnHiatus,
|
||||
};
|
||||
|
||||
class RNBH implements Plugin.PluginBase {
|
||||
id = "RNBH.org";
|
||||
name = "RanobeHub";
|
||||
@@ -14,10 +20,13 @@ class RNBH implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/api/search?page=" + pageNo + "&sort=";
|
||||
url += showLatestNovels
|
||||
url += showLatestNovels
|
||||
? "last_chapter_at"
|
||||
: filters?.sort?.value || "computed_rating";
|
||||
url += "&status=" + (filters?.status?.value ? filters?.status?.value : "0");
|
||||
@@ -30,7 +39,9 @@ class RNBH implements Plugin.PluginBase {
|
||||
const includeTags = [
|
||||
filters.tags?.value?.include,
|
||||
filters.events?.value?.include,
|
||||
].flat().filter((t) => t);
|
||||
]
|
||||
.flat()
|
||||
.filter((t) => t);
|
||||
|
||||
if (includeTags.length) {
|
||||
url += "&tags:positive=" + includeTags.join(",");
|
||||
@@ -39,7 +50,9 @@ class RNBH implements Plugin.PluginBase {
|
||||
const excludeTags = [
|
||||
filters.tags?.value?.exclude,
|
||||
filters.events?.value?.exclude,
|
||||
].flat().filter((t) => t);
|
||||
]
|
||||
.flat()
|
||||
.filter((t) => t);
|
||||
|
||||
if (excludeTags.length) {
|
||||
url += "&tags:negative=" + excludeTags.join(",");
|
||||
@@ -54,29 +67,24 @@ class RNBH implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.names.rus || novel.names.eng || novel.names.original,
|
||||
cover: novel.poster.medium,
|
||||
url: novel.url,
|
||||
path: "/ranobe/" + novel.id,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novelId = novelUrl
|
||||
.substring("https://ranobehub.org/ranobe/".length)
|
||||
.split("-")[0];
|
||||
const result = await fetchApi(this.site + "/api/ranobe/" + novelId);
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(this.site + "/api" + novelPath);
|
||||
const json = (await result.json()) as { data: responseNovel };
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: json.data.names?.rus || json.data.names.eng,
|
||||
path: novelPath,
|
||||
name: json.data.names.rus || json.data.names.eng || "",
|
||||
cover: json.data.posters.medium,
|
||||
summary: json.data.description,
|
||||
summary: json.data.description.trim(),
|
||||
author: json.data?.authors?.[0]?.name_eng || "",
|
||||
status: json.data.status.title.includes("процессе")
|
||||
? NovelStatus.Ongoing
|
||||
: NovelStatus.Completed,
|
||||
status: statusKey[json.data.status.id] || NovelStatus.Unknown,
|
||||
};
|
||||
|
||||
const tags = [json.data.tags.events, json.data.tags.genres]
|
||||
@@ -89,28 +97,33 @@ class RNBH implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
const chaptersRaw = await fetchApi(`${this.site}/api/ranobe/${novelId}/contents`);
|
||||
const chaptersRaw = await fetchApi(
|
||||
this.site + "/api" + novelPath + "/contents",
|
||||
);
|
||||
const chaptersJSON = (await chaptersRaw.json()) as {
|
||||
volumes: VolumesEntity[];
|
||||
};
|
||||
|
||||
chaptersJSON.volumes.forEach((volume) =>
|
||||
volume.chapters?.forEach((chapter) => {
|
||||
chapters.push({
|
||||
name: chapter.name,
|
||||
url: chapter.url,
|
||||
releaseTime: dayjs(parseInt(chapter.changed_at, 10) * 1000).format("LLL"),
|
||||
chapterNumber: chapters.length + 1,
|
||||
});
|
||||
}),
|
||||
volume.chapters?.forEach((chapter) =>
|
||||
chapters.push({
|
||||
name: chapter.name,
|
||||
path:
|
||||
volume.num && chapter.num
|
||||
? novelPath + "/" + volume.num + "/" + chapter.num
|
||||
: chapter.url.replace(this.site, ""),
|
||||
releaseTime: dayjs(parseInt(chapter.changed_at, 10) * 1000).format("LLL"),
|
||||
chapterNumber: chapters.length + 1,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
novel.chapters = chapters;
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const result = await fetchApi(chapterUrl);
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(this.site + chapterPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -132,10 +145,7 @@ class RNBH implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
//pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/api/fulltext/global?query=${searchTerm}&take=10`;
|
||||
const result = await fetchApi(url);
|
||||
const data = (await result.json()) as responseSearch[];
|
||||
@@ -151,11 +161,7 @@ class RNBH implements Plugin.PluginBase {
|
||||
novel.name ||
|
||||
novel?.names?.original ||
|
||||
"",
|
||||
url:
|
||||
"https://ranobehub.org/ranobe/" +
|
||||
novel?.url?.match(
|
||||
/https:\/\/ranobehub\.org\/ranobe\/(.*?)\?utm_source=search_name&utm_medium=search&utm_campaign=search_using/,
|
||||
)?.[1],
|
||||
path: "/ranobe/" + novel.id,
|
||||
cover: novel?.image?.replace("/small", "/medium"),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -5,12 +5,12 @@ import { NovelStatus } from "@libs/novelStatus";
|
||||
import { load as parseHTML } from "cheerio";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const statusKey = [
|
||||
NovelStatus.Ongoing,
|
||||
NovelStatus.Completed,
|
||||
NovelStatus.OnHiatus,
|
||||
NovelStatus.Cancelled,
|
||||
];
|
||||
const statusKey: { [key: number]: string } = {
|
||||
1: NovelStatus.Ongoing,
|
||||
2: NovelStatus.Completed,
|
||||
3: NovelStatus.OnHiatus,
|
||||
4: NovelStatus.Cancelled,
|
||||
};
|
||||
|
||||
class RLIB implements Plugin.PluginBase {
|
||||
id = "RLIB";
|
||||
@@ -22,22 +22,26 @@ class RLIB implements Plugin.PluginBase {
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/manga-list?sort=";
|
||||
url += showLatestNovels ? "last_chapter_at" : filters?.sort?.value || "rate";
|
||||
url += "&dir=" + (filters?.order?.value || "desc");
|
||||
url += "&chapters[min]=" + (filters?.require_chapters?.value ? "1" : "0");
|
||||
|
||||
Object.entries(filters || {}).forEach(([type, { value }]: any) => {
|
||||
if (value instanceof Array && value.length) {
|
||||
url += "&" + type + "[]=" + value.join("&" + type + "[]=");
|
||||
}
|
||||
if (value?.include instanceof Array && value.include.length) {
|
||||
url += "&" + type + "[include][]=" +
|
||||
url += "&" + type + "[include][]=" +
|
||||
value.include.join("&" + type + "[include][]=");
|
||||
}
|
||||
}
|
||||
if (value?.exclude instanceof Array && value.exclude.length) {
|
||||
url += "&" + type + "[exclude][]=" +
|
||||
url += "&" + type + "[exclude][]=" +
|
||||
value.exclude.join("&" + type + "[exclude][]=");
|
||||
}
|
||||
});
|
||||
@@ -51,27 +55,25 @@ class RLIB implements Plugin.PluginBase {
|
||||
?.replace?.(/[^0-9]/g, "");
|
||||
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
loadedCheerio(".media-card-wrap").each(function () {
|
||||
const name = loadedCheerio(this).find(".media-card__title").text();
|
||||
const cover = loadedCheerio(this).find("a.media-card").attr("data-src");
|
||||
const url = loadedCheerio(this).find("a.media-card").attr("href");
|
||||
loadedCheerio(".media-card-wrap").each((index, element) => {
|
||||
const name = loadedCheerio(element).find(".media-card__title").text();
|
||||
const cover = loadedCheerio(element).find("a.media-card").attr("data-src");
|
||||
const url = loadedCheerio(element).find("a.media-card").attr("href");
|
||||
if (!url) return;
|
||||
novels.push({ name, cover, url });
|
||||
novels.push({ name, cover, path: url.replace(this.site, "") });
|
||||
});
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(novelUrl).then((res) => res.text());
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const body = await fetchApi(this.site + novelPath).then((res) => res.text());
|
||||
const loadedCheerio = parseHTML(body);
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
path: novelPath,
|
||||
name: loadedCheerio(".media-name__main").text()?.trim?.() || "",
|
||||
};
|
||||
|
||||
novel.name = loadedCheerio(".media-name__main").text().trim();
|
||||
|
||||
novel.cover = loadedCheerio(".container_responsive img").attr("src");
|
||||
|
||||
novel.summary = loadedCheerio(".media-description__text").text().trim();
|
||||
@@ -102,45 +104,75 @@ class RLIB implements Plugin.PluginBase {
|
||||
}
|
||||
});
|
||||
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
const chaptersRaw = body.match(/window\.__DATA__ = ({.*?});/);
|
||||
if (chaptersRaw instanceof Array && chaptersRaw.length >= 2) {
|
||||
const chaptersJson: responseBook = JSON.parse(chaptersRaw[1]);
|
||||
|
||||
let chaptersRaw: any = body.match(
|
||||
/window.__DATA__ = [\s\S]*?window._SITE_COLOR_/gm,
|
||||
);
|
||||
if (!novel.name) {
|
||||
novel.name =
|
||||
chaptersJson.manga.rusName ||
|
||||
chaptersJson.manga.engName ||
|
||||
chaptersJson.manga.name;
|
||||
}
|
||||
novel.status = statusKey[chaptersJson.manga.status] || NovelStatus.Unknown;
|
||||
this.ui = chaptersJson?.user?.id;
|
||||
|
||||
chaptersRaw = chaptersRaw?.[0]
|
||||
?.replace("window.__DATA__ = ", "")
|
||||
?.replace("window._SITE_COLOR_", "")
|
||||
?.trim()
|
||||
?.slice(0, -1);
|
||||
if (!chaptersJson.chapters.list?.length) return novel;
|
||||
const totalChapters = chaptersJson.chapters.list.length;
|
||||
|
||||
const chaptersJson: responseBook = JSON.parse(chaptersRaw);
|
||||
const totalChapters = chaptersJson.chapters.list?.length || 0;
|
||||
novel.status = statusKey[chaptersJson.manga.status - 1] || NovelStatus.Unknown;
|
||||
this.ui = chaptersJson?.user?.id;
|
||||
const customPage: { [key: number]: string } = {};
|
||||
const customOrder: { [key: number]: number } = {};
|
||||
if (chaptersJson.chapters.branches?.length && chaptersJson.chapters.branches.length > 1) {
|
||||
//if the novel is being translated by more than one team
|
||||
chaptersJson.chapters.branches.forEach(({ teams, id }) => {
|
||||
if (teams?.length) {
|
||||
customPage[id || 0] =
|
||||
teams.find((team) => team.is_active)?.name || teams[0].name;
|
||||
}
|
||||
});
|
||||
//fixes the chapter's position.
|
||||
chaptersJson.chapters.list.forEach((chapter) => {
|
||||
chapter.index = customOrder[chapter.branch_id || 0] || 1;
|
||||
customOrder[chapter.branch_id || 0] =
|
||||
(customOrder[chapter.branch_id || 0] || 1) + 1;
|
||||
});
|
||||
};
|
||||
|
||||
chaptersJson.chapters?.list?.forEach((chapter, chapterIndex) =>
|
||||
chapters.push({
|
||||
name:
|
||||
"Том " + chapter.chapter_volume +
|
||||
" Глава " + chapter.chapter_number +
|
||||
(chapter.chapter_name ? " " + chapter.chapter_name.trim() : ""),
|
||||
url:
|
||||
this.site + "/" + chaptersJson.manga.slug +
|
||||
"/v" + chapter.chapter_volume + "/c" + chapter.chapter_number +
|
||||
"?bid=" + (chapter.branch_id || ""),
|
||||
releaseTime: dayjs(chapter.chapter_created_at).format("LLL"),
|
||||
chapterNumber: totalChapters - chapterIndex,
|
||||
}),
|
||||
);
|
||||
|
||||
novel.chapters = chapters.reverse();
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
chaptersJson.chapters.list.forEach((chapter, chapterIndex) =>
|
||||
chapters.push({
|
||||
name:
|
||||
"Том " + chapter.chapter_volume +
|
||||
" Глава " + chapter.chapter_number +
|
||||
(chapter.chapter_name ? " " + chapter.chapter_name.trim() : ""),
|
||||
path:
|
||||
"/" + chaptersJson.manga.slug +
|
||||
"/v" + chapter.chapter_volume +
|
||||
"/c" + chapter.chapter_number +
|
||||
"?bid=" + (chapter.branch_id || ""),
|
||||
releaseTime: dayjs(chapter.chapter_created_at).format("LLL"),
|
||||
chapterNumber:
|
||||
customOrder[chapter.branch_id || 0] - (chapter.index || 0) ||
|
||||
totalChapters - chapterIndex,
|
||||
page: customPage[chapter.branch_id || 0] || "Основной перевод",
|
||||
}),
|
||||
);
|
||||
novel.chapters =
|
||||
chaptersJson.chapters.branches?.length &&
|
||||
chaptersJson.chapters.branches.length > 1
|
||||
? chapters.sort((a, b) => {
|
||||
if ((a.page || 0) > (b.page || 0)) return 1;
|
||||
if ((a.page || 0) < (b.page || 0)) return -1;
|
||||
return (a.chapterNumber || 0) - (b.chapterNumber || 0);
|
||||
})
|
||||
: chapters.reverse();
|
||||
}
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(
|
||||
chapterUrl + (this.ui ? "&ui=" + this.ui : ""),
|
||||
this.site + chapterPath + (this.ui ? "&ui=" + this.ui : ""),
|
||||
).then((res) => res.text());
|
||||
|
||||
const loadedCheerio = parseHTML(result);
|
||||
@@ -160,21 +192,18 @@ class RLIB implements Plugin.PluginBase {
|
||||
return chapterText || "";
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
//pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const result = await fetchApi(
|
||||
`${this.site}/search?q=${searchTerm}&type=manga`,
|
||||
this.site + "/search?q=" + searchTerm + "&type=manga",
|
||||
);
|
||||
const body = (await result.json()) as Manga[];
|
||||
const novels: Plugin.NovelItem[] = [];
|
||||
|
||||
body.forEach((novel) =>
|
||||
novels.push({
|
||||
name: novel?.rus_name || novel.name,
|
||||
cover: novel?.coverImage,
|
||||
url: novel?.href || this.site + "/" + novel.slug,
|
||||
name: novel.rus_name || novel.name,
|
||||
cover: novel.coverImage,
|
||||
path: "/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -396,6 +425,11 @@ class RLIB implements Plugin.PluginBase {
|
||||
],
|
||||
type: FilterTypes.ExcludableCheckboxGroup,
|
||||
},
|
||||
require_chapters: {
|
||||
label: "Только проекты с главами",
|
||||
value: true,
|
||||
type: FilterTypes.Switch,
|
||||
},
|
||||
} satisfies Filters;
|
||||
}
|
||||
|
||||
@@ -424,12 +458,13 @@ interface Manga {
|
||||
href?: string;
|
||||
}
|
||||
interface Chapters {
|
||||
list?: ListEntity[] | null;
|
||||
teams?: TeamsEntity[] | null;
|
||||
branches?: BranchesEntity[] | null;
|
||||
is_paid?: null[] | null;
|
||||
list?: ListEntity[];
|
||||
teams?: TeamsEntity[];
|
||||
branches?: BranchesEntity[];
|
||||
is_paid?: string[] | null;
|
||||
}
|
||||
interface ListEntity {
|
||||
index?: number; //crutch
|
||||
chapter_id: number;
|
||||
chapter_slug: string;
|
||||
chapter_name: string;
|
||||
|
||||
+13
-13
@@ -37,15 +37,15 @@ class RNRF implements Plugin.PluginBase {
|
||||
cover: novel?.verticalImage?.url
|
||||
? this.site + novel.verticalImage.url
|
||||
: defaultCover,
|
||||
url: this.site + "/" + novel.slug,
|
||||
path: "/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(novelUrl);
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const result = await fetchApi(this.site + novelPath);
|
||||
const body = await result.text();
|
||||
|
||||
const loadedCheerio = parseHTML(body);
|
||||
@@ -53,8 +53,8 @@ class RNRF implements Plugin.PluginBase {
|
||||
const book = (JSON.parse(jsonRaw || "{}") as response).props.pageProps.book;
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: book?.title,
|
||||
path: novelPath,
|
||||
name: book?.title || "",
|
||||
cover: book?.verticalImage?.url
|
||||
? this.site + book.verticalImage.url
|
||||
: defaultCover,
|
||||
@@ -72,7 +72,7 @@ class RNRF implements Plugin.PluginBase {
|
||||
if (!chapter.isDonate || chapter.isUserPaid) {
|
||||
chapters.push({
|
||||
name: chapter.title,
|
||||
url: this.site + chapter.url,
|
||||
path: chapter.url,
|
||||
releaseTime: dayjs(chapter.publishedAt).format("LLL"),
|
||||
chapterNumber: book.chapters.length - chapterIndex,
|
||||
});
|
||||
@@ -83,8 +83,10 @@ class RNRF implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const result = await fetchApi(chapterUrl).then((res) => res.text());
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const result = await fetchApi(this.site + chapterPath).then((res) =>
|
||||
res.text(),
|
||||
);
|
||||
|
||||
let loadedCheerio = parseHTML(result);
|
||||
const jsonRaw = loadedCheerio("#__NEXT_DATA__").html();
|
||||
@@ -105,10 +107,7 @@ class RNRF implements Plugin.PluginBase {
|
||||
return chapterText;
|
||||
}
|
||||
|
||||
async searchNovels(
|
||||
searchTerm: string,
|
||||
//pageNo: number | undefined = 1,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
|
||||
const url = `${this.site}/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()) as { items: Item[] };
|
||||
@@ -120,12 +119,13 @@ class RNRF implements Plugin.PluginBase {
|
||||
cover: novel?.verticalImage?.url
|
||||
? this.site + novel.verticalImage.url
|
||||
: defaultCover,
|
||||
url: this.site + "/" + novel.slug,
|
||||
path: "/" + novel.slug,
|
||||
}),
|
||||
);
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
fetchImage = fetchFile;
|
||||
|
||||
filters = {
|
||||
|
||||
+32
-35
@@ -4,32 +4,34 @@ import { fetchApi, fetchFile } from "@libs/fetch";
|
||||
import { NovelStatus } from "@libs/novelStatus";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
||||
|
||||
class ReN implements Plugin.PluginBase {
|
||||
id = "ReN";
|
||||
name = "Renovels";
|
||||
icon = "src/ru/renovels/icon.png";
|
||||
site = "https://renovels.org";
|
||||
version = "1.0.0";
|
||||
icon = "src/ru/renovels/icon.png";
|
||||
|
||||
async popularNovels(
|
||||
pageNo: number,
|
||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let url = this.site + "/api/search/catalog/?count=30&ordering=";
|
||||
url += filters?.order?.value ? "-" : "";
|
||||
let url = this.site + "/api/search/catalog/?count=30&ordering=-";
|
||||
url += showLatestNovels ? "chapter_date" : filters?.sort?.value || "rating";
|
||||
|
||||
Object.entries(filters || {}).forEach(([type, { value }]: any) => {
|
||||
if (value instanceof Array && value.length) {
|
||||
url += "&" + type + "=" +
|
||||
value.join("&" + type + "=");
|
||||
url += "&" + type + "=" + value.join("&" + type + "=");
|
||||
}
|
||||
if (value?.include instanceof Array && value.include.length) {
|
||||
url += "&" + type + "=" +
|
||||
value.include.join("&" + type + "=");
|
||||
url += "&" + type + "=" + value.include.join("&" + type + "=");
|
||||
}
|
||||
if (value?.exclude instanceof Array && value.exclude.length) {
|
||||
url += "&exclude_" + type + "=" +
|
||||
url += "&exclude_" + type + "=" +
|
||||
value.exclude.join("&exclude_" + type + "=");
|
||||
}
|
||||
});
|
||||
@@ -42,26 +44,27 @@ class ReN implements Plugin.PluginBase {
|
||||
const novels: Plugin.NovelItem[] = body.content.map((novel) => ({
|
||||
name: novel.main_name || novel.secondary_name,
|
||||
cover: this.site + (novel.img.high || novel.img.mid || novel.img.low),
|
||||
url: this.site + "/novel/" + novel.dir,
|
||||
path: "/novel/" + novel.dir,
|
||||
}));
|
||||
|
||||
return novels;
|
||||
}
|
||||
|
||||
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||
const novelID = novelUrl.split("/")[4];
|
||||
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
|
||||
const novelID = novelPath.split("/")[2];
|
||||
const result = await fetchApi(this.site + "/api/titles/" + novelID);
|
||||
const body = (await result.json()) as { content: responseNovel };
|
||||
|
||||
const novel: Plugin.SourceNovel = {
|
||||
url: novelUrl,
|
||||
name: body.content.main_name || body.content.secondary_name || body.content.another_name,
|
||||
path: novelPath,
|
||||
name:
|
||||
body.content.main_name ||
|
||||
body.content.secondary_name ||
|
||||
body.content.another_name,
|
||||
summary: body.content.description,
|
||||
cover:
|
||||
this.site +
|
||||
(body.content.img.high ||
|
||||
body.content.img.mid ||
|
||||
body.content.img.low),
|
||||
(body.content.img.high || body.content.img.mid || body.content.img.low),
|
||||
status:
|
||||
body.content.status.name === "Продолжается"
|
||||
? NovelStatus.Ongoing
|
||||
@@ -77,15 +80,18 @@ class ReN implements Plugin.PluginBase {
|
||||
novel.genres = tags.join(",");
|
||||
}
|
||||
|
||||
const all = body.content.count_chapters / 100 + 1;
|
||||
const totalPages =
|
||||
(body.content.branches?.[0]?.count_chapters ||
|
||||
body.content.count_chapters) / 100;
|
||||
const branch_id = body.content.branches?.[0]?.id || body.content.id;
|
||||
const chapters: Plugin.ChapterItem[] = [];
|
||||
|
||||
for (let i = 0; i < all; i++) {
|
||||
for (let page = 0; page < totalPages; page++) {
|
||||
await delay(1000);
|
||||
const chapterResult = await fetchApi(
|
||||
this.site +
|
||||
"/api/titles/chapters/?branch_id=" + branch_id +
|
||||
"&count=100&page=" + (i + 1),
|
||||
"&count=100&page=" + (page + 1),
|
||||
);
|
||||
const volumes = (await chapterResult.json()) as {
|
||||
content: responseСhapters[];
|
||||
@@ -95,10 +101,10 @@ class ReN implements Plugin.PluginBase {
|
||||
if (!chapter.is_paid || chapter.is_bought) {
|
||||
chapters.push({
|
||||
name:
|
||||
"Том " + chapter.tome +
|
||||
" Глава " + chapter.chapter +
|
||||
"Том " + chapter.tome +
|
||||
" Глава " + chapter.chapter +
|
||||
(chapter.name ? " " + chapter.name.trim() : ""),
|
||||
url: `${this.site}/novel/${novelID}/${chapter.id}/`,
|
||||
path: "/novel/" + novelID + "/" + chapter.id,
|
||||
releaseTime: dayjs(chapter.upload_date).format("LLL"),
|
||||
chapterNumber: chapter.index,
|
||||
});
|
||||
@@ -110,8 +116,8 @@ class ReN implements Plugin.PluginBase {
|
||||
return novel;
|
||||
}
|
||||
|
||||
async parseChapter(chapterUrl: string): Promise<string> {
|
||||
const url = this.site + "/api/titles/chapters/" + chapterUrl.split("/")[5];
|
||||
async parseChapter(chapterPath: string): Promise<string> {
|
||||
const url = this.site + "/api/titles/chapters/" + chapterPath.split("/")[3];
|
||||
const result = await fetchApi(url);
|
||||
const body = (await result.json()) as { content: responseСhapter };
|
||||
|
||||
@@ -131,7 +137,7 @@ class ReN implements Plugin.PluginBase {
|
||||
novels.push({
|
||||
name: novel.main_name || novel.secondary_name,
|
||||
cover: this.site + (novel.img.high || novel.img.mid || novel.img.low),
|
||||
url: this.site + "/novel/" + novel.dir,
|
||||
path: "/novel/" + novel.dir,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -154,15 +160,6 @@ class ReN implements Plugin.PluginBase {
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
order: {
|
||||
label: "Порядок",
|
||||
value: "-",
|
||||
options: [
|
||||
{ label: "По убыванию", value: "-" },
|
||||
{ label: "По возрастанию", value: "" },
|
||||
],
|
||||
type: FilterTypes.Picker,
|
||||
},
|
||||
genres: {
|
||||
label: "Жанры:",
|
||||
value: { include: [], exclude: [] },
|
||||
|
||||
Reference in New Issue
Block a user