From c47c0429178a418bb8e78540bc0d82d2038a890e Mon Sep 17 00:00:00 2001 From: Rushil Perera Date: Sat, 8 Jun 2024 11:43:17 -0400 Subject: [PATCH] fix: use anify as last source if other sources aren't recognized --- .../episodes/getEpisodeUrl/index.ts | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/controllers/episodes/getEpisodeUrl/index.ts b/src/controllers/episodes/getEpisodeUrl/index.ts index 2b68cfd..303db94 100644 --- a/src/controllers/episodes/getEpisodeUrl/index.ts +++ b/src/controllers/episodes/getEpisodeUrl/index.ts @@ -94,26 +94,6 @@ app.openapi(route, async (c) => { } } - if (provider === "anify") { - try { - const result = await import("./anify").then(({ getSourcesFromAnify }) => - getSourcesFromAnify(provider, id, aniListId), - ); - if (!result) { - return c.json({ success: false }, { status: 404 }); - } - - return c.json({ - success: true, - result, - }); - } catch (e) { - console.error("Failed to fetch download URL from Anify", e); - - return c.json(ErrorResponse, { status: 500 }); - } - } - if (provider === "amvstrm") { try { const result = await import("./amvstrm").then( @@ -134,7 +114,23 @@ app.openapi(route, async (c) => { } } - return c.json(ErrorResponse, { status: 400 }); + try { + const result = await import("./anify").then(({ getSourcesFromAnify }) => + getSourcesFromAnify(provider, id, aniListId), + ); + if (!result) { + return c.json({ success: false }, { status: 404 }); + } + + return c.json({ + success: true, + result, + }); + } catch (e) { + console.error("Failed to fetch download URL from Anify", e); + + return c.json(ErrorResponse, { status: 500 }); + } }); export default app;