Skip to content

Commit

Permalink
fix: no subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 2, 2023
1 parent e920df5 commit ccb4796
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pages/api/summarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export default async function handler(
// @ts-ignore
const title = res.data?.title;
const subtitleList = res.data?.subtitle?.list;
if (subtitleList && subtitleList.length < 1) {
if (!subtitleList || subtitleList?.length === 0) {
return new Response("No subtitle in the video", { status: 501 });
}
const betterSubtitle =
subtitleList.find(({ lan }: { lan: string }) => lan === "zh-CN") ||
subtitleList?.[0];
subtitleList[0];
const subtitleUrl = betterSubtitle?.subtitle_url;
console.log("subtitle_url", subtitleUrl);

Expand All @@ -57,7 +57,6 @@ export default async function handler(
const prompt = getSummaryPrompt(title, text);

try {

apiKey && console.log("========use user key========");
const payload = {
model: "gpt-3.5-turbo",
Expand Down

1 comment on commit ccb4796

@vercel
Copy link

@vercel vercel bot commented on ccb4796 Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.