Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ export default tseslint.config(
},
},
{
files: ['**/*.{ts,tsx,mts,cts,js}'],
files: ['**/*.{ts,tsx,mts,cts,js,cjs}'],
ignores: ['./plugins/*/*.ts', './plugins/multisrc/*/template.ts'],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
Expand All @@ -191,7 +192,14 @@ export default tseslint.config(
globals: {
...globals.serviceworker,
...globals.browser,
...globals.node,
},
},
},
{
files: ['**/fictioneer/custom/*/*.js'],
rules: {
'no-undef': 'off',
},
},
);
42 changes: 22 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 32 additions & 22 deletions plugins/arabic/dilartube.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CheerioAPI, load as parseHTML } from 'cheerio';
import { load as parseHTML } from 'cheerio';
import { fetchApi } from '@libs/fetch';
import { Plugin } from '@/types/plugin';
import { Filters, FilterTypes } from '@libs/filterInputs';
import { Filters } from '@libs/filterInputs';
import { defaultCover } from '@libs/defaultCover';

class dilartube implements Plugin.PluginBase {
id = 'dilartube';
name = 'dilar tube';
version = '1.0.1';
version = '1.0.2';
icon = 'src/ar/dilartube/icon.png';
site = 'https://golden.rest/';

Expand Down Expand Up @@ -53,7 +53,7 @@ class dilartube implements Plugin.PluginBase {

async popularNovels(
page: number,
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
{ showLatestNovels }: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
let link = `${this.site}api/releases?page=${page}`;
if (showLatestNovels) {
Expand Down Expand Up @@ -82,36 +82,38 @@ class dilartube implements Plugin.PluginBase {
const chapterItems: Plugin.ChapterItem[] = [];
const fullUrl = this.site + 'api/' + novelUrl;
const chapterUrl = this.site + 'api/' + novelUrl + '/releases';
const manga = await fetchApi(fullUrl).then(r => r.json());
const manga: MangaResponse = await fetchApi(fullUrl).then(r => r.json());
const chapters = await fetchApi(chapterUrl).then(r => r.json());
const mangaData = manga.mangaData;
const chapterData = chapters.releases;

const novel: Plugin.SourceNovel = {
path: novelUrl,
name: mangaData.arabic_title || 'Untitled',
name: mangaData.arabic_title ?? mangaData.title ?? 'Untitled',
author:
(mangaData.authors.length > 0 ? mangaData.authors[0].name : '') ||
'Unknown',
summary: mangaData.summary || '',
cover: `${this.site}uploads/manga/cover/${mangaData.id}/${mangaData.cover}`,
chapters: [],
};
const translationStatusId: string = mangaData.translation_status;
const translationStatusId = mangaData.translation_status.toString();
const translationText =
{
'1': 'مستمره',
'0': 'منتهية',
'2': 'متوقفة',
'3': 'غير مترجمه',
}[translationStatusId] || 'غير معروف';
const statusWords = new Set(['مكتمل', 'جديد', 'مستمر']);
const mainGenres = mangaData.categories
.map((category: { name: any }) => category.name)
// const statusWords = new Set(['مكتمل', 'جديد', 'مستمر']);
const mainGenres = Array.from(
new Set(mangaData.categories.map(g => g.name)),
)
.filter(Boolean)
.join(',');
novel.genres = `${translationText},${mainGenres}`;

const statusId: string = mangaData.story_status;
const statusId = mangaData.story_status.toString();
const statusText =
{
'2': 'Ongoing',
Expand All @@ -138,12 +140,18 @@ class dilartube implements Plugin.PluginBase {
const parsedData = JSON.parse(jsonData as string);

const chapterText = parsedData.readerDataAction.readerData.release.content;
return chapterText;
// return html with p tags
return chapterText
.split(/\r?\n/)
.map((line: string) => line.trim())
.filter(Boolean)
.map((line: string) => `<p>${line}</p>`)
.join('');
}

async searchNovels(
searchTerm: string,
page: number,
// page: number,
): Promise<Plugin.NovelItem[]> {
const formData = new FormData();
formData.append('query', searchTerm);
Expand All @@ -156,6 +164,7 @@ class dilartube implements Plugin.PluginBase {
return this.parseNovels(data);
}

filters: Filters | undefined = undefined;
// filters = {
// types: {
// value: [],
Expand Down Expand Up @@ -245,8 +254,8 @@ type Manga = {
publisher_name: string | null;
discord_url: string | null;
mobile_exclusive: boolean;
authors: any[];
artists: any[];
// authors: any[];
// artists: any[];
categories: Category[];
type: Type;
};
Expand Down Expand Up @@ -327,7 +336,7 @@ type MangaData = {
uniq_visitors_count: number;
publisher_id: number | null;
publisher_name: string | null;
arabic_title: string;
arabic_title: string | null;
english: string;
synonyms: string;
japanese: string;
Expand Down Expand Up @@ -360,11 +369,12 @@ type MangaData = {
};

type MangaResponse = {
membersMentioning: any[];
memberRates: any | null;
mangaLogs: Record<string, any>;
// membersMentioning: any[];
// memberRates: any | null;
// mangaLogs: Record<string, any>;
mangaData: MangaData;
};

type ChapterRelease = {
id: number;
manga_id: number;
Expand All @@ -385,7 +395,7 @@ type ChapterRelease = {
has_rev_link: boolean;
};
type searchManga = {
filter: any;
// filter: any;
id: number;
title: string;
summary: string;
Expand Down Expand Up @@ -417,8 +427,8 @@ type searchManga = {
publisher_name: string | null;
discord_url: string | null;
mobile_exclusive: boolean;
authors: any[];
artists: any[];
// authors: any[];
// artists: any[];
categories: Category[];
type: Type;
};
11 changes: 7 additions & 4 deletions plugins/arabic/rewayatclub.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheerioAPI, load as parseHTML } from 'cheerio';
import { load as parseHTML } from 'cheerio';
import { fetchApi } from '@libs/fetch';
import { Plugin } from '@/types/plugin';
import { Filters, FilterTypes } from '@libs/filterInputs';
Expand All @@ -7,7 +7,7 @@ import { defaultCover } from '@libs/defaultCover';
class RewayatClub implements Plugin.PagePlugin {
id = 'rewayatclub';
name = 'Rewayat Club';
version = '1.0.2';
version = '1.0.3';
icon = 'src/ar/rewayatclub/icon.png';
site = 'https://rewayat.club/';

Expand All @@ -34,7 +34,10 @@ class RewayatClub implements Plugin.PagePlugin {

async popularNovels(
page: number,
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
let link = `https://api.rewayat.club/api/novels/`;
let body: NovelData = {
Expand Down Expand Up @@ -253,7 +256,7 @@ type ChapterEntry = {
hits: number;
id: number;
};
read: any[];
// read: any[];
};

type ChapterData = {
Expand Down
9 changes: 4 additions & 5 deletions plugins/arabic/sunovels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { defaultCover } from '@libs/defaultCover';
class Sunovels implements Plugin.PagePlugin {
id = 'sunovels';
name = 'Sunovels';
version = '1.0.0';
version = '1.0.1';
icon = 'src/ar/sunovels/icon.png';
site = 'https://sunovels.com/';

Expand Down Expand Up @@ -52,7 +52,7 @@ class Sunovels implements Plugin.PagePlugin {

async popularNovels(
page: number,
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
const pageCorrected = page - 1;
let link = `${this.site}library?`;
Expand Down Expand Up @@ -137,7 +137,7 @@ class Sunovels implements Plugin.PagePlugin {
name: item.chapterName,
releaseTime: new Date(item.releaseTime).toISOString(),
path: item.chapterUrl,
chapterNumber: item.chapterNumber,
chapterNumber: Number(item.chapterNumber),
});
});
return chapter;
Expand Down Expand Up @@ -169,8 +169,7 @@ class Sunovels implements Plugin.PagePlugin {
const dateAttr = loadedCheerio(el)
.find('time.chapter-update')
.attr('datetime');
const date = new Date(dateAttr);
const releaseTime = date.toISOString();
const releaseTime = dateAttr ? new Date(dateAttr).toISOString() : '';
const chapternumber = loadedCheerio(el)
.find('strong.chapter-title')
.text()
Expand Down
8 changes: 4 additions & 4 deletions plugins/chinese/Quanben.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const parseUrl = (url?: string): URL | undefined => {
const getStandardNovelPath = (url?: string): string | undefined => {
const parsedUrl = parseUrl(url);
if (!parsedUrl) return undefined;
const match = parsedUrl.pathname.match(/^(\/amp)?(\/n\/[^\/]+\/)/);
const match = parsedUrl.pathname.match(/^(\/amp)?(\/n\/[^/]+\/)/);
return match?.[2];
};

Expand Down Expand Up @@ -47,7 +47,7 @@ class QuanbenPlugin implements Plugin.PluginBase {
id = 'quanben';
name = 'Quanben';
site = 'https://www.quanben.io/';
version = '1.0.1';
version = '1.0.2';
icon = 'src/cn/quanben/icon.png';
defaultCover = defaultCover;

Expand Down Expand Up @@ -180,7 +180,7 @@ class QuanbenPlugin implements Plugin.PluginBase {

const $ = parseHTML(await res.text());
const chapters: Plugin.ChapterItem[] = [];
const novelName = novelPath.match(/\/n\/([^\/]+)\//)?.[1];
const novelName = novelPath.match(/\/n\/([^/]+)\//)?.[1];
if (!novelName) return [];

$('ul.list3 li a').each((_i, el) => {
Expand Down Expand Up @@ -224,7 +224,7 @@ class QuanbenPlugin implements Plugin.PluginBase {
// Helper function to extract and clean chapter content from HTML body
private extractChapterContent(body: string): string {
const $ = parseHTML(body);
let $content = $('#contentbody, #content, .content').first();
const $content = $('#contentbody, #content, .content').first();
if (!$content.length) return 'Error: Chapter content not found.';

$content
Expand Down
Loading
Loading