diff --git a/pages/api/summarize.ts b/pages/api/summarize.ts index 194d694d..132f4a75 100644 --- a/pages/api/summarize.ts +++ b/pages/api/summarize.ts @@ -1,4 +1,4 @@ -import { find } from "lodash"; +import find from "lodash"; import { NextResponse } from "next/server"; import { Redis } from "@upstash/redis"; import type { NextFetchEvent, NextRequest } from "next/server"; @@ -40,7 +40,9 @@ export default async function handler( if (subtitleList && subtitleList.length < 1) { return new Response("No subtitle in the video", { status: 501 }); } - const betterSubtitle = find(subtitleList, { lan: "zh-CN" }) || subtitleList?.[0] + const betterSubtitle = + subtitleList.find(({ lan }: { lan: string }) => lan === "zh-CN") || + subtitleList?.[0]; const subtitleUrl = betterSubtitle?.subtitle_url; console.log("bvid", bvId); console.log("subtitle_url", subtitleUrl);