- 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
- The
<body>
of HomePage is written inpages/[...slug].tsx
. - 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
- 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.- use the fetchSubtitle( ) function(file path:
lib/fetchSubtitle.ts
) to get the { title, subtitlesArray, descriptionText } - use the getUserSubtitlePrompt( ) function(file path:
lib/openai/prompt.ts
) to give an template format for the constrcuted userPrompt. - constrcut the openAiPayload and use the fetchOpenAIResult( ) function(file path:
lib/openai/fetchOpenAIResult.ts
) to get the formatted answer generated by chatGPT API.
- use the fetchSubtitle( ) function(file path:
I have added the function fetchBilibiliCommentsUrls( )(path: lib/bilibili/fetchBilibiliCommentsUrls.ts
). Use:
const commentInfo = await fetchBilibiliCommentsUrls(videoId, pageNumber)
const {comment} = commentInfo
The data/commentObjectExample.txt
shows the output format.
like
means "该评论的点赞数"message
means "评论的内容"
I have added the function fetchBilibiliBarrageUrls( )(path: lib/bilibili/fetchBilibiliBarrageUrls.ts
).