From a0d039ecc120cfeb8352c6b525ee1e766555f9ec Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 28 Apr 2024 10:26:39 +0200 Subject: [PATCH] feat: added the ability to grab episode sources from raw servers in endpoint `/episode-srcs` --- README.md | 2 +- src/parsers/animeEpisodeSrcs.ts | 2 +- src/types/anime.ts | 1 + src/utils/methods.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d80b96f..784e7ed 100644 --- a/README.md +++ b/README.md @@ -922,7 +922,7 @@ https://api-aniwatch.onrender.com/anime/episode-srcs?id={episodeId}&server={serv | :--------: | :----: | :-------------------------------------------: | :-------: | :--------------: | | `id` | string | The id of the episode. | Yes | -- | | `server` | string | The name of the server. | No | `"vidstreaming"` | -| `category` | string | The category of the episode ('sub' or 'dub'). | No | `"sub"` | +| `category` | string | The category of the episode ('sub', 'dub' or 'raw'). | No | `"sub"` | #### Request sample diff --git a/src/parsers/animeEpisodeSrcs.ts b/src/parsers/animeEpisodeSrcs.ts index 104bc4d..913c535 100644 --- a/src/parsers/animeEpisodeSrcs.ts +++ b/src/parsers/animeEpisodeSrcs.ts @@ -25,7 +25,7 @@ import { type ScrapedAnimeEpisodesSources } from "../types/parsers/index.js"; async function scrapeAnimeEpisodeSources( episodeId: string, server: AnimeServers = Servers.VidStreaming, - category: "sub" | "dub" = "sub" + category: "sub" | "dub" | "raw" = "sub" ): Promise { if (episodeId.startsWith("http")) { const serverUrl = new URL(episodeId); diff --git a/src/types/anime.ts b/src/types/anime.ts index abb15f2..9af00bc 100644 --- a/src/types/anime.ts +++ b/src/types/anime.ts @@ -75,6 +75,7 @@ export interface SubEpisode { serverId: number | null; } export interface DubEpisode extends SubEpisode {} +export interface RawEpisode extends SubEpisode {} export type AnimeCategories = | "most-favorite" diff --git a/src/utils/methods.ts b/src/utils/methods.ts index 9d89822..1ed0c88 100644 --- a/src/utils/methods.ts +++ b/src/utils/methods.ts @@ -191,7 +191,7 @@ export const extractMostPopularAnimes = ( export function retrieveServerId( $: CheerioAPI, index: number, - category: "sub" | "dub" + category: "sub" | "dub" | "raw" ) { return ( $(`.ps_-block.ps_-block-sub.servers-${category} > .ps__-list .server-item`)