From ae1f6c1407999ea338d2c5d7f45da42466d568e6 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Sun, 10 Dec 2023 00:59:17 +0800 Subject: [PATCH] Opt: conver to srt start counter is zero --- server/handlers/movie.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/handlers/movie.go b/server/handlers/movie.go index 3b16b6f..46fd2ca 100644 --- a/server/handlers/movie.go +++ b/server/handlers/movie.go @@ -873,11 +873,14 @@ func initBilibiliSubtitleCache(ctx context.Context, movie dbModel.Movie) func() func convertToSRT(subtitles bilibiliSubtitleResp) []byte { srt := bytes.NewBuffer(nil) - counter := 1 + counter := 0 for _, subtitle := range subtitles.Body { - start := formatTime(subtitle.From) - end := formatTime(subtitle.To) - srt.WriteString(fmt.Sprintf("%d\n%s --> %s\n%s\n\n", counter, start, end, subtitle.Content)) + srt.WriteString( + fmt.Sprintf("%d\n%s --> %s\n%s\n\n", + counter, + formatTime(subtitle.From), + formatTime(subtitle.To), + subtitle.Content)) counter++ } return srt.Bytes()