Skip to content

Commit

Permalink
refactor: add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 8, 2023
1 parent 0d674d9 commit 2eccaa3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/reduceSubtitleTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export type YoutubeSubtitleItem = { start: number; lines: string[] };
export function reduceSubtitleTimestamp(
subtitles: Array<YoutubeSubtitleItem>
): Array<CommonSubtitleItem> {
// 把字幕数组分成 10 组
const groupCount = 20;
// 把字幕数组总共分成 20 组
const TOTAL_GROUP_COUNT = 20;
// 如果字幕不够多,就每三组合并一下
const MINIMUM_COUNT_ONE_GROUP = 3;
const eachGroupCount =
subtitles.length > groupCount
? subtitles.length / groupCount
: subtitles.length;
subtitles.length > TOTAL_GROUP_COUNT
? subtitles.length / TOTAL_GROUP_COUNT
: MINIMUM_COUNT_ONE_GROUP;

return subtitles.reduce(
(
Expand Down

1 comment on commit 2eccaa3

@vercel
Copy link

@vercel vercel bot commented on 2eccaa3 Mar 8, 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.