diff --git a/anify-backend/src/mappings/impl/manga/novelhall.ts b/anify-backend/src/mappings/impl/manga/novelhall.ts new file mode 100644 index 0000000..dbdaf57 --- /dev/null +++ b/anify-backend/src/mappings/impl/manga/novelhall.ts @@ -0,0 +1,80 @@ +import { load } from "cheerio"; +import MangaProvider from "."; +import { Format } from "../../../types/enums"; +import { Chapter, Page, Result } from "../../../types/types"; + +export default class NovelHall extends MangaProvider { + override rateLimit = 1000; + override id = "novelhall"; + override url = "https://novelhall.com"; + + public needsProxy: boolean = false; + + override formats: Format[] = [Format.NOVEL]; + + override async search(query: string): Promise { + const results: Result[] = []; + + const data = await ( + await this.request(`${this.url}/index.php?s=so&module=book&keyword=${encodeURIComponent(query)}`, { + method: "GET", + headers: { + Referer: this.url, + }, + }) + ).text(); + + const $ = load(data); + + $("table tr").each((i, el) => { + const item = $(el).find("td a").toArray(); + const element = item[1]; + + const title = $(element).text().trim(); + const id = $(element).attr("href") ?? ""; + + results.push({ + id, + title, + img: "", + altTitles: [], + format: Format.NOVEL, + providerId: this.id, + year: 0, + }); + }); + + return results; + } + + override async fetchChapters(id: string): Promise { + const chapters: Chapter[] = []; + + const data = await (await this.request(`${this.url}${id}`)).text(); + + const $ = load(data); + + for (let i = 0; i < $("div#morelist.book-catalog ul li a").length; i++) { + const el = $("div#morelist.book-catalog ul li a").toArray()[i]; + + const title = $(el).text(); + const id = $(el).attr("href") ?? ""; + + chapters.push({ + id, + title, + number: i + 1, + rating: null, + }); + } + + return chapters; + } + + override async fetchPages(id: string): Promise { + const data = await (await this.request(`${this.url}${id}`)).text(); + + const $ = load(data); + return $("div#htmlContent.entry-content").toString(); + } +} diff --git a/anify-backend/src/mappings/index.ts b/anify-backend/src/mappings/index.ts index 80c0966..d056e4a 100644 --- a/anify-backend/src/mappings/index.ts +++ b/anify-backend/src/mappings/index.ts @@ -28,6 +28,7 @@ import Mangakakalot from "./impl/manga/mangakakalot"; import MangaPill from "./impl/manga/mangapill"; import MangaSee from "./impl/manga/mangasee"; import NovelUpdates from "./impl/manga/novelupdates"; +import NovelHall from "./impl/manga/novelhall"; import MetaProvider from "./impl/meta"; import AniDBMeta from "./impl/meta/anidb"; import AniListMeta from "./impl/meta/anilist"; @@ -45,7 +46,7 @@ const animeProviders: Record = ANIME_PROVIDERS.reduce( {} as Record, ); -const MANGA_PROVIDERS: MangaProvider[] = [new ComicK(), new MangaDex(), new MangaSee(), new MangaFire(), new Mangakakalot(), new MangaPill(), new JNovels(), new NovelUpdates(), new FirstKissNovel()]; +const MANGA_PROVIDERS: MangaProvider[] = [new ComicK(), new MangaDex(), new MangaSee(), new MangaFire(), new Mangakakalot(), new MangaPill(), new JNovels(), new NovelUpdates(), new FirstKissNovel(), new NovelHall()]; const mangaProviders: Record = MANGA_PROVIDERS.reduce( (acc, provider) => { acc[provider.id] = provider;