feat: Add Dilar.tube (#1170)
* Add files via upload * 2nd * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * another change with image * clean up * clean up * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories * fix handling single chapter stories and minor cleanup * fix handling single chapter stories and minor cleanup * New source test * New source test * fix bugs * fix bugs * fix bugs * bugs fix * New arabic source rewayat.club * New arabic source rewayat.club * New arabic source rewayat.club * New arabic source rewayat.club * chapter release dates improvment for ao3 * edits * add chapter dates to ao3 * add chapter dates to ao3 * improve RewayatClub * new source sunovels * new source sunovels * fix images in source sunovels * fix images in source sunovels * fix filters in source sunovels * fix filters in source sunovels * fix filters in source sunovels * fix filters in source sunovels * fix filters in source sunovels * fix filters in source sunovels * fix filters in source sunovels * Update src/plugins/arabic/sunovels.ts Co-authored-by: K1ngfish3r <trulyihu@gmail.com> * Update src/plugins/arabic/sunovels.ts Co-authored-by: K1ngfish3r <trulyihu@gmail.com> * fix test newsource * fix test newsource * fix test newsource * fix test newsource * fix test newsource * Update dilartube.ts * Update dilartube.ts * Update dilartube.ts * fix test newsource * Update rewayatclub.ts * fix test newsource * edits to multiple sources * edits to multiple sources * Rewayat * edits to multiple sources --------- Co-authored-by: K1ngfish3r <trulyihu@gmail.com>
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,424 @@
|
|||||||
|
import { CheerioAPI, load as parseHTML } from 'cheerio';
|
||||||
|
import { fetchApi } from '@libs/fetch';
|
||||||
|
import { Plugin } from '@typings/plugin';
|
||||||
|
import { Filters, FilterTypes } from '@libs/filterInputs';
|
||||||
|
import { defaultCover } from '@libs/defaultCover';
|
||||||
|
|
||||||
|
class dilartube implements Plugin.PluginBase {
|
||||||
|
id = 'dilartube';
|
||||||
|
name = 'dilar tube';
|
||||||
|
version = '1.0.0';
|
||||||
|
icon = 'src/ar/dilartube/icon.png';
|
||||||
|
site = 'https://dilar.tube/';
|
||||||
|
|
||||||
|
parseNovels(data: ApiResponse): Plugin.NovelItem[] {
|
||||||
|
const novels: Plugin.NovelItem[] = [];
|
||||||
|
const seenTitles = new Set<string>();
|
||||||
|
if (data.data && data.data.length > 0) {
|
||||||
|
data.data
|
||||||
|
.filter(dataItem => dataItem.is_novel)
|
||||||
|
.forEach(dataItem => {
|
||||||
|
const manga = dataItem;
|
||||||
|
if (!seenTitles.has(dataItem.title)) {
|
||||||
|
seenTitles.add(manga.title);
|
||||||
|
novels.push({
|
||||||
|
name: dataItem.title || 'novel',
|
||||||
|
path: `mangas/${manga.id}`,
|
||||||
|
cover: manga.cover
|
||||||
|
? `${this.site}uploads/manga/cover/${manga.id}/${manga.cover}`
|
||||||
|
: defaultCover,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (data.releases && data.releases.length > 0) {
|
||||||
|
data.releases
|
||||||
|
.filter(release => release.manga.is_novel)
|
||||||
|
.forEach(release => {
|
||||||
|
const manga = release.manga;
|
||||||
|
if (!seenTitles.has(manga.title)) {
|
||||||
|
seenTitles.add(manga.title);
|
||||||
|
novels.push({
|
||||||
|
name: manga.title || 'novel',
|
||||||
|
path: `mangas/${manga.id}`,
|
||||||
|
cover: manga.cover
|
||||||
|
? `${this.site}uploads/manga/cover/${manga.id}/${manga.cover}`
|
||||||
|
: defaultCover,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return novels;
|
||||||
|
}
|
||||||
|
|
||||||
|
async popularNovels(
|
||||||
|
page: number,
|
||||||
|
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
|
||||||
|
): Promise<Plugin.NovelItem[]> {
|
||||||
|
let link = `${this.site}api/releases?page=${page}`;
|
||||||
|
if (showLatestNovels) {
|
||||||
|
link = `${this.site}api/releases?page=${page}`;
|
||||||
|
}
|
||||||
|
// if (filters) {
|
||||||
|
// if (
|
||||||
|
// Array.isArray(filters.categories.value) &&
|
||||||
|
// filters.categories.value.length > 0
|
||||||
|
// ) {
|
||||||
|
// filters.categories.value.forEach((genre: string) => {
|
||||||
|
// link += `&category=${genre}`;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// if (filters.status.value !== '') {
|
||||||
|
// link += `&status=${filters.status.value}`;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// link += `?page=${page}`;
|
||||||
|
// const body = await fetchApi(link).then(r => r.text());
|
||||||
|
const response = await fetchApi(link).then(r => r.json());
|
||||||
|
return this.parseNovels(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
async parseNovel(novelUrl: string): Promise<Plugin.SourceNovel> {
|
||||||
|
const chapterItems: Plugin.ChapterItem[] = [];
|
||||||
|
let fullUrl = this.site + 'api/' + novelUrl;
|
||||||
|
let chapterUrl = this.site + 'api/' + novelUrl + '/releases';
|
||||||
|
const manga = 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',
|
||||||
|
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 translationText =
|
||||||
|
{
|
||||||
|
'1': 'مستمره',
|
||||||
|
'0': 'منتهية',
|
||||||
|
'2': 'متوقفة',
|
||||||
|
'3': 'غير مترجمه',
|
||||||
|
}[translationStatusId] || 'غير معروف';
|
||||||
|
const statusWords = new Set(['مكتمل', 'جديد', 'مستمر']);
|
||||||
|
const mainGenres = mangaData.categories
|
||||||
|
.map((category: { name: any }) => category.name)
|
||||||
|
.join(',');
|
||||||
|
novel.genres = `${translationText},${mainGenres}`;
|
||||||
|
|
||||||
|
const statusId: string = mangaData.story_status;
|
||||||
|
const statusText =
|
||||||
|
{
|
||||||
|
'2': 'Ongoing',
|
||||||
|
'3': 'Completed',
|
||||||
|
}[statusId] || 'Unknown';
|
||||||
|
novel.status = statusText;
|
||||||
|
chapterData.map((item: ChapterRelease) => {
|
||||||
|
chapterItems.push({
|
||||||
|
name: item.title,
|
||||||
|
releaseTime: new Date(item.created_at).toISOString(),
|
||||||
|
path: `${novelUrl}/${mangaData.title.replace(' ', '-')}/${item.chapter}`,
|
||||||
|
chapterNumber: item.chapter,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
novel.chapters = chapterItems.reverse();
|
||||||
|
return novel;
|
||||||
|
}
|
||||||
|
async parseChapter(chapterUrl: string): Promise<string> {
|
||||||
|
const result = await fetchApi(new URL(chapterUrl, this.site).toString());
|
||||||
|
const body = await result.text();
|
||||||
|
const loadedCheerio = parseHTML(body);
|
||||||
|
|
||||||
|
const jsonData = loadedCheerio('script.js-react-on-rails-component').html();
|
||||||
|
const parsedData = JSON.parse(jsonData as string);
|
||||||
|
|
||||||
|
const chapterText = parsedData.readerDataAction.readerData.release.content;
|
||||||
|
return chapterText;
|
||||||
|
}
|
||||||
|
|
||||||
|
async searchNovels(
|
||||||
|
searchTerm: string,
|
||||||
|
page: number,
|
||||||
|
): Promise<Plugin.NovelItem[]> {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('query', searchTerm);
|
||||||
|
formData.append('includes', '["Manga","Team","Member"]');
|
||||||
|
const response = await fetchApi('https://dilar.tube/api/quick_search', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
}).then(r => r.json());
|
||||||
|
const data: ApiResponse = response[0];
|
||||||
|
return this.parseNovels(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filters = {
|
||||||
|
// types: {
|
||||||
|
// value: [],
|
||||||
|
// label: 'الأنواع',
|
||||||
|
// options: [
|
||||||
|
// { label: 'يابانية', value: '1' }, // Japanese
|
||||||
|
// { label: 'كورية', value: '2' }, // Korean
|
||||||
|
// { label: 'صينية', value: '3' }, // Chinese
|
||||||
|
// { label: 'عربية', value: '4' }, // Arabic
|
||||||
|
// { label: 'كوميك', value: '5' }, // Comic
|
||||||
|
// { label: 'هواة', value: '6' }, // Amateur
|
||||||
|
// { label: 'إندونيسية', value: '7' }, // Indonesian
|
||||||
|
// { label: 'روسية', value: '8' }, // Russian
|
||||||
|
// ],
|
||||||
|
// type: FilterTypes.CheckboxGroup,
|
||||||
|
// },
|
||||||
|
|
||||||
|
// status: {
|
||||||
|
// value: '',
|
||||||
|
// label: 'الحالة',
|
||||||
|
// options: [
|
||||||
|
// { label: 'مستمرة', value: '2' }, // Ongoing
|
||||||
|
// { label: 'منتهية', value: '3' }, // Completed
|
||||||
|
// ],
|
||||||
|
// type: FilterTypes.CheckboxGroup,
|
||||||
|
// },
|
||||||
|
|
||||||
|
// translation: {
|
||||||
|
// value: [],
|
||||||
|
// label: 'الترجمة',
|
||||||
|
// options: [
|
||||||
|
// { label: 'منتهية', value: '0' }, // Completed
|
||||||
|
// { label: 'مستمرة', value: '1' }, // Ongoing
|
||||||
|
// { label: 'متوقفة', value: '2' }, // Paused
|
||||||
|
// { label: 'غير مترجمة', value: '3' }, // Not Translated
|
||||||
|
// ],
|
||||||
|
// type: FilterTypes.CheckboxGroup,
|
||||||
|
// },
|
||||||
|
// } satisfies Filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new dilartube();
|
||||||
|
|
||||||
|
interface Category {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
icon: string | null;
|
||||||
|
manga_id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Type {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
reading_direction: string;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Manga {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
summary: string;
|
||||||
|
is_novel: boolean;
|
||||||
|
is_oneshot: boolean;
|
||||||
|
genre_id: number;
|
||||||
|
cover: string;
|
||||||
|
cover_pos: number;
|
||||||
|
rectangle_cover_pos: number;
|
||||||
|
banner: string;
|
||||||
|
manga_type_id: number;
|
||||||
|
reading_direction: string;
|
||||||
|
story_status: number;
|
||||||
|
translation_status: number;
|
||||||
|
vols: number;
|
||||||
|
chaps: number;
|
||||||
|
reviewed: boolean;
|
||||||
|
banned: boolean;
|
||||||
|
rating: string;
|
||||||
|
rates_count: number;
|
||||||
|
commentable: boolean;
|
||||||
|
show_comments: boolean;
|
||||||
|
deleted_at: string | null;
|
||||||
|
delete_reason: string;
|
||||||
|
time_stamp: number;
|
||||||
|
latest_chapterization_id: number;
|
||||||
|
uniq_visitors_count: number;
|
||||||
|
publisher_id: number | null;
|
||||||
|
publisher_name: string | null;
|
||||||
|
discord_url: string | null;
|
||||||
|
mobile_exclusive: boolean;
|
||||||
|
authors: any[];
|
||||||
|
artists: any[];
|
||||||
|
categories: Category[];
|
||||||
|
type: Type;
|
||||||
|
}
|
||||||
|
interface Release {
|
||||||
|
id: number;
|
||||||
|
manga_id: number;
|
||||||
|
created_at: string;
|
||||||
|
time_stamp: number;
|
||||||
|
views: number;
|
||||||
|
encoded: boolean;
|
||||||
|
showable: boolean;
|
||||||
|
link_control: number;
|
||||||
|
support_link: string;
|
||||||
|
creator_id: number;
|
||||||
|
chapterization_id: number;
|
||||||
|
chapter: number;
|
||||||
|
volume: number;
|
||||||
|
title: string;
|
||||||
|
team_id: number;
|
||||||
|
team_name: string;
|
||||||
|
team_rating: string;
|
||||||
|
team_settings: string;
|
||||||
|
team_paypal: string | null;
|
||||||
|
has_rev_link: boolean;
|
||||||
|
manga: Manga;
|
||||||
|
}
|
||||||
|
interface ApiResponse {
|
||||||
|
releases: Release[];
|
||||||
|
data: searchManga[];
|
||||||
|
}
|
||||||
|
type MangaCategory = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
icon: string | null;
|
||||||
|
manga_id: number;
|
||||||
|
};
|
||||||
|
type AuthorArtist = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
manga_id: number;
|
||||||
|
role: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type MangaType = {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
reading_direction: string;
|
||||||
|
title: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type MangaData = {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
summary: string;
|
||||||
|
is_novel: boolean;
|
||||||
|
is_oneshot: boolean;
|
||||||
|
genre_id: number;
|
||||||
|
cover: string;
|
||||||
|
cover_pos: number;
|
||||||
|
rectangle_cover_pos: number;
|
||||||
|
banner: string;
|
||||||
|
manga_type_id: number;
|
||||||
|
reading_direction: string;
|
||||||
|
story_status: number;
|
||||||
|
translation_status: number;
|
||||||
|
vols: number;
|
||||||
|
chaps: number;
|
||||||
|
reviewed: boolean;
|
||||||
|
banned: boolean;
|
||||||
|
rating: string;
|
||||||
|
rates_count: number;
|
||||||
|
commentable: boolean;
|
||||||
|
show_comments: boolean;
|
||||||
|
deleted_at: string | null;
|
||||||
|
delete_reason: string | null;
|
||||||
|
time_stamp: number;
|
||||||
|
latest_chapterization_id: number;
|
||||||
|
uniq_visitors_count: number;
|
||||||
|
publisher_id: number | null;
|
||||||
|
publisher_name: string | null;
|
||||||
|
arabic_title: string;
|
||||||
|
english: string;
|
||||||
|
synonyms: string;
|
||||||
|
japanese: string;
|
||||||
|
over17: boolean;
|
||||||
|
s_date: string;
|
||||||
|
e_date: string | null;
|
||||||
|
mal: string;
|
||||||
|
mangaupdates: string;
|
||||||
|
mangadex: string | null;
|
||||||
|
anilist: string;
|
||||||
|
official_site: string | null;
|
||||||
|
manga_fox: string | null;
|
||||||
|
wikia: string | null;
|
||||||
|
mangarock_oid: string | null;
|
||||||
|
comicvine_id: string | null;
|
||||||
|
external_source: string | null;
|
||||||
|
discord_url: string | null;
|
||||||
|
discord_id: string | null;
|
||||||
|
anime_start_end: string | null;
|
||||||
|
creator_id: number;
|
||||||
|
creator_nick: string;
|
||||||
|
editor_id: number;
|
||||||
|
editor_nick: string;
|
||||||
|
mobile_exclusive: boolean;
|
||||||
|
authors: AuthorArtist[];
|
||||||
|
artists: AuthorArtist[];
|
||||||
|
categories: MangaCategory[];
|
||||||
|
type: MangaType;
|
||||||
|
memberRating: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type MangaResponse = {
|
||||||
|
membersMentioning: any[];
|
||||||
|
memberRates: any | null;
|
||||||
|
mangaLogs: Record<string, any>;
|
||||||
|
mangaData: MangaData;
|
||||||
|
};
|
||||||
|
type ChapterRelease = {
|
||||||
|
id: number;
|
||||||
|
manga_id: number;
|
||||||
|
created_at: string; // ISO 8601 date string
|
||||||
|
time_stamp: number;
|
||||||
|
views: number;
|
||||||
|
link_control: number;
|
||||||
|
support_link: string;
|
||||||
|
init_team: number;
|
||||||
|
creator_id: number;
|
||||||
|
chapterization_id: number;
|
||||||
|
chapterization_time_stamp: number;
|
||||||
|
chapter: number;
|
||||||
|
volume: number;
|
||||||
|
title: string;
|
||||||
|
team_id: number;
|
||||||
|
team_name: string;
|
||||||
|
has_rev_link: boolean;
|
||||||
|
};
|
||||||
|
interface searchManga {
|
||||||
|
filter: any;
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
summary: string;
|
||||||
|
is_novel: boolean;
|
||||||
|
is_oneshot: boolean;
|
||||||
|
genre_id: number;
|
||||||
|
cover: string;
|
||||||
|
cover_pos: number;
|
||||||
|
rectangle_cover_pos: number;
|
||||||
|
banner: string;
|
||||||
|
manga_type_id: number;
|
||||||
|
reading_direction: string;
|
||||||
|
story_status: number;
|
||||||
|
translation_status: number;
|
||||||
|
vols: number;
|
||||||
|
chaps: number;
|
||||||
|
reviewed: boolean;
|
||||||
|
banned: boolean;
|
||||||
|
rating: string;
|
||||||
|
rates_count: number;
|
||||||
|
commentable: boolean;
|
||||||
|
show_comments: boolean;
|
||||||
|
deleted_at: string | null;
|
||||||
|
delete_reason: string;
|
||||||
|
time_stamp: number;
|
||||||
|
latest_chapterization_id: number;
|
||||||
|
uniq_visitors_count: number;
|
||||||
|
publisher_id: number | null;
|
||||||
|
publisher_name: string | null;
|
||||||
|
discord_url: string | null;
|
||||||
|
mobile_exclusive: boolean;
|
||||||
|
authors: any[];
|
||||||
|
artists: any[];
|
||||||
|
categories: Category[];
|
||||||
|
type: Type;
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import { defaultCover } from '@libs/defaultCover';
|
|||||||
class RewayatClub implements Plugin.PagePlugin {
|
class RewayatClub implements Plugin.PagePlugin {
|
||||||
id = 'rewayatclub';
|
id = 'rewayatclub';
|
||||||
name = 'Rewayat Club';
|
name = 'Rewayat Club';
|
||||||
version = '1.0.0';
|
version = '1.0.1';
|
||||||
icon = 'src/ar/rewayatclub/icon.png';
|
icon = 'src/ar/rewayatclub/icon.png';
|
||||||
site = 'https://rewayat.club/';
|
site = 'https://rewayat.club/';
|
||||||
|
|
||||||
@@ -15,9 +15,17 @@ class RewayatClub implements Plugin.PagePlugin {
|
|||||||
const novels: Plugin.NovelItem[] = [];
|
const novels: Plugin.NovelItem[] = [];
|
||||||
data.results.map((item: NovelEntry) => {
|
data.results.map((item: NovelEntry) => {
|
||||||
novels.push({
|
novels.push({
|
||||||
name: item.arabic,
|
name: item.arabic || item.novel?.arabic || 'novel',
|
||||||
path: `novel/${item.slug}`,
|
path: item.slug
|
||||||
cover: `https://api.rewayat.club/${item.poster_url.slice(1)}`,
|
? `novel/${item.slug}`
|
||||||
|
: item.novel
|
||||||
|
? `novel/${item.novel.slug}`
|
||||||
|
: 'novel',
|
||||||
|
cover: item.poster_url
|
||||||
|
? `https://api.rewayat.club/${item.poster_url.slice(1)}`
|
||||||
|
: item.novel
|
||||||
|
? `https://api.rewayat.club/${item.novel.poster_url.slice(1)}`
|
||||||
|
: defaultCover,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return novels;
|
return novels;
|
||||||
@@ -28,8 +36,16 @@ class RewayatClub implements Plugin.PagePlugin {
|
|||||||
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
|
{ showLatestNovels, filters }: Plugin.PopularNovelsOptions<Filters>,
|
||||||
): Promise<Plugin.NovelItem[]> {
|
): Promise<Plugin.NovelItem[]> {
|
||||||
let link = `https://api.rewayat.club/api/novels/`;
|
let link = `https://api.rewayat.club/api/novels/`;
|
||||||
|
let body: NovelData = {
|
||||||
if (filters) {
|
count: 0,
|
||||||
|
next: '',
|
||||||
|
previous: '',
|
||||||
|
results: [],
|
||||||
|
};
|
||||||
|
if (showLatestNovels) {
|
||||||
|
link = `${this.site}api/chapters/weekly/list/?page=${page}`;
|
||||||
|
body = await fetchApi(link).then(r => r.json());
|
||||||
|
} else if (filters) {
|
||||||
if (filters.categories.value !== '') {
|
if (filters.categories.value !== '') {
|
||||||
link += `?type=${filters.categories.value}`;
|
link += `?type=${filters.categories.value}`;
|
||||||
}
|
}
|
||||||
@@ -41,10 +57,9 @@ class RewayatClub implements Plugin.PagePlugin {
|
|||||||
link += `&genre=${genre}`;
|
link += `&genre=${genre}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
link += `&page=${page}`;
|
||||||
|
body = await fetchApi(link).then(r => r.json());
|
||||||
}
|
}
|
||||||
link += `&page=${page}`;
|
|
||||||
const body = await fetchApi(link).then(r => r.json());
|
|
||||||
const loadedCheerio = parseHTML(body);
|
|
||||||
return this.parseNovels(body);
|
return this.parseNovels(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,22 +140,12 @@ class RewayatClub implements Plugin.PagePlugin {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
async parseChapter(chapterUrl: string): Promise<string> {
|
async parseChapter(chapterUrl: string): Promise<string> {
|
||||||
const result = await fetchApi(new URL(chapterUrl, this.site).toString());
|
let link = this.site + 'api/chapters/' + chapterUrl.slice(6);
|
||||||
const body = await result.text();
|
const result = await fetchApi(link).then(r => r.json());
|
||||||
const loadedCheerio = parseHTML(body);
|
let chapterText = result.content
|
||||||
let chapterText = '';
|
.flat()
|
||||||
loadedCheerio('div.v-card--flat').each((idx, ele) => {
|
.join('')
|
||||||
loadedCheerio(ele)
|
.replace(/<p>\n|\n<p>\n/g, '');
|
||||||
.find('div.v-card__text')
|
|
||||||
.each((idx, textEle) => {
|
|
||||||
chapterText +=
|
|
||||||
loadedCheerio(textEle)
|
|
||||||
.find('p')
|
|
||||||
.map((_, pEle) => loadedCheerio(pEle).text().trim())
|
|
||||||
.get()
|
|
||||||
.join(' ') + ' ';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
chapterText = chapterText.trim();
|
chapterText = chapterText.trim();
|
||||||
return chapterText;
|
return chapterText;
|
||||||
}
|
}
|
||||||
@@ -152,8 +157,6 @@ class RewayatClub implements Plugin.PagePlugin {
|
|||||||
const searchUrl = `https://api.rewayat.club/api/novels/?type=0&ordering=-num_chapters&page=${page}&search=${searchTerm}`;
|
const searchUrl = `https://api.rewayat.club/api/novels/?type=0&ordering=-num_chapters&page=${page}&search=${searchTerm}`;
|
||||||
|
|
||||||
const result = await fetchApi(searchUrl).then(r => r.json());
|
const result = await fetchApi(searchUrl).then(r => r.json());
|
||||||
// const body = await result.text();
|
|
||||||
// const loadedCheerio = parseHTML(body);
|
|
||||||
return this.parseNovels(result);
|
return this.parseNovels(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,11 +223,20 @@ interface NovelEntry {
|
|||||||
arabic: string;
|
arabic: string;
|
||||||
english: string;
|
english: string;
|
||||||
};
|
};
|
||||||
|
novel?: {
|
||||||
|
arabic: string;
|
||||||
|
english: string;
|
||||||
|
slug: string;
|
||||||
|
poster: string;
|
||||||
|
id: number;
|
||||||
|
poster_url: string;
|
||||||
|
original: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
interface NovelData {
|
interface NovelData {
|
||||||
count: number;
|
count?: number;
|
||||||
next: string;
|
next?: string;
|
||||||
previous: string;
|
previous?: string;
|
||||||
results: NovelEntry[];
|
results: NovelEntry[];
|
||||||
}
|
}
|
||||||
interface ChapterEntry {
|
interface ChapterEntry {
|
||||||
|
|||||||
Reference in New Issue
Block a user