Skip to content

Commit

Permalink
feat: NovelHall
Browse files Browse the repository at this point in the history
  • Loading branch information
Eltik committed Apr 12, 2024
1 parent a4ff3d8 commit ce65206
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
80 changes: 80 additions & 0 deletions anify-backend/src/mappings/impl/manga/novelhall.ts
Original file line number Diff line number Diff line change
@@ -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<Result[] | undefined> {
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<Chapter[] | undefined> {
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<Page[] | string | undefined> {
const data = await (await this.request(`${this.url}${id}`)).text();

const $ = load(data);
return $("div#htmlContent.entry-content").toString();
}
}
3 changes: 2 additions & 1 deletion anify-backend/src/mappings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -45,7 +46,7 @@ const animeProviders: Record<string, AnimeProvider> = ANIME_PROVIDERS.reduce(
{} as Record<string, AnimeProvider>,
);

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<string, MangaProvider> = MANGA_PROVIDERS.reduce(
(acc, provider) => {
acc[provider.id] = provider;
Expand Down

0 comments on commit ce65206

Please sign in to comment.