kkdai / youtube

Download Youtube Video in Golang
MIT License
3.3k stars 430 forks source link

Improve Subtitle Timestamp Precision or Provide SRT Download Option #333

Closed Yuelioi closed 2 months ago

Yuelioi commented 2 months ago

I want to download subtitles, process them, and then translate them. Therefore, I need higher timestamp precision. Alternatively, if it's possible to directly download the subtitles in SRT format, that would be even better.

The client.GetTranscript(video, lang) function does not provide subtitles with timestamps in milliseconds, resulting in inaccuracies that make it challenging to process and translate the subtitles.

Expected Behavior

Some function return subtitles with timestamps in milliseconds for higher precision.

Code

transcript, err := client.GetTranscript(video, "en")

if err != nil {
    return
}

fmt.Printf("%v\n", transcript.String())

Additional Information

0:00 - what up today we're going to go over my
0:01 - process of how I'm making money as a
0:03 - freelance web developer while I'm job
0:05 - hunt so for me I have a family to take
0:07 - care of while I'm in the process of
Yuelioi commented 2 months ago

Sorry, while debugging the source code, I found that the transcript is a []TranscriptSegment which contains all the information.