Skip to content

Commit

Permalink
feat: throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Feb 27, 2023
1 parent f0f96cb commit 3f86565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const Home: NextPage = () => {

if (!response.ok) {
console.log("error", response.statusText);
toast.error("啊叻?视频字幕不见了?!");
return;
}

Expand Down Expand Up @@ -151,7 +152,7 @@ export const Home: NextPage = () => {
{summary && (
<div className="mb-10 px-4">
<h2 className="mx-auto mt-16 max-w-3xl border-t border-gray-600 pt-8 text-center text-3xl font-bold sm:text-5xl">
【总结】
📝 总结】
</h2>
<div className="mx-auto mt-6 max-w-3xl text-lg leading-7">
{summary.split("- ").map((sentence, index) => (
Expand Down
5 changes: 4 additions & 1 deletion pages/api/summarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default async function handler(req: Request) {
const title = res.data.title;
const subtitleUrl = res.data.subtitle?.list?.[0]?.subtitle_url;
console.log("subtitle_url", subtitleUrl);
if (!subtitleUrl) {
return new Response("No subtitle in the video", { status: 500 });
}

const subtitleResponse = await fetch(subtitleUrl);
const subtitles = await subtitleResponse.json();
Expand All @@ -46,7 +49,7 @@ export default async function handler(req: Request) {
timestamp: item.from,
};
});
console.log("========transcripts========", transcripts);
// console.log("========transcripts========", transcripts);
const text = getChunckedTranscripts(transcripts, transcripts);
const prompt = getSummaryPrompt(title, text);

Expand Down

1 comment on commit 3f86565

@vercel
Copy link

@vercel vercel bot commented on 3f86565 Feb 27, 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.