feat: add Consumet as provider for stream URL
Summary: Test Plan:
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import { ANIME, META } from "@consumet/extensions";
|
||||
import fetchAdapter from "@haverstack/axios-fetch-adapter";
|
||||
import { aniList } from "~/consumet";
|
||||
|
||||
import { Episode, EpisodesResponse } from "./episode";
|
||||
|
||||
export async function getEpisodesFromConsumet(
|
||||
aniListId: number,
|
||||
): Promise<EpisodesResponse | null> {
|
||||
const gogoAnime = new ANIME.Gogoanime(undefined, undefined, fetchAdapter);
|
||||
const aniList = new META.Anilist(gogoAnime, undefined, fetchAdapter);
|
||||
|
||||
try {
|
||||
const episodes: Episode[] = await aniList
|
||||
.fetchEpisodesListById(aniListId.toString())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
||||
|
||||
import { fetchFromMultipleSources } from "~/libs/fetchFromMultipleSources";
|
||||
import { readEnvVariable } from "~/libs/readEnvVariable";
|
||||
import type { Env } from "~/types/env";
|
||||
import {
|
||||
AniListIdQuerySchema,
|
||||
@@ -49,11 +50,10 @@ app.openapi(route, async (c) => {
|
||||
const aniListId = Number(c.req.param("aniListId"));
|
||||
|
||||
const episodes = await fetchFromMultipleSources([
|
||||
() =>
|
||||
getEpisodesFromAnify(
|
||||
JSON.parse((c.env?.["ENABLE_ANIFY"] ?? "true") as string),
|
||||
aniListId,
|
||||
),
|
||||
() => {
|
||||
const isAnifyEnabled = readEnvVariable<boolean>(c.env, "ENABLE_ANIFY");
|
||||
return getEpisodesFromAnify(isAnifyEnabled, aniListId);
|
||||
},
|
||||
() =>
|
||||
import("./consumet").then(({ getEpisodesFromConsumet }) =>
|
||||
getEpisodesFromConsumet(aniListId),
|
||||
|
||||
Reference in New Issue
Block a user