/OurProject

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

OurProject

Deploy

  • Use node 18(run node -v to check)
  • Run npm install
  • Run npm run dev

If you want to launch data storage server:

  • Set env variables in .env
DATA_SERVER_ENABLE=true
DATA_SERVER_HOSTNAME=http://localhost:5001
  • cd server
  • node server.js

Then it will store the video data, user prompt and the result to the folder data

Main Workflow

  1. The <body> of HomePage is written in pages/[...slug].tsx.
  2. When we click the "一键总结" button, the async function generateSummary( ) will be called, which will wait for the result of another function summarize( ) defined in hooks/useSummarize.ts
  3. Next, it will POST the /api/sumup(file path is: pages/api/sumup.ts), and in the handler function, we process the request in 3 steps.
    1. use the fetchSubtitle( ) function(file path: lib/fetchSubtitle.ts) to get the { title, subtitlesArray, descriptionText }
    2. use the getUserSubtitlePrompt( ) function(file path: lib/openai/prompt.ts) to give an template format for the constrcuted userPrompt.
    3. constrcut the openAiPayload and use the fetchOpenAIResult( ) function(file path: lib/openai/fetchOpenAIResult.ts) to get the formatted answer generated by chatGPT API.

fetch comments function

I have added the function fetchBilibiliCommentsUrls( )(path: lib/bilibili/fetchBilibiliCommentsUrls.ts). Use:

  1. const commentInfo = await fetchBilibiliCommentsUrls(videoId, pageNumber)
  2. const {comment} = commentInfo

The data/commentObjectExample.txt shows the output format.

  • like means "该评论的点赞数"
  • message means "评论的内容"

fetch Barrage function

I have added the function fetchBilibiliBarrageUrls( )(path: lib/bilibili/fetchBilibiliBarrageUrls.ts).