Created
January 13, 2021 07:15
-
-
Save rabbitix/d6a2956f1f237dffa361523db6cdf9f3 to your computer and use it in GitHub Desktop.
download caption of a yt video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pytube import YouTube | |
source = YouTube('https://www.youtube.com/watch?v=KR0g-1hnQPA&feature=emb_logo') | |
en_caption = source.captions.get_by_language_code('en') | |
en_caption_convert_to_srt =(en_caption.generate_srt_captions()) | |
print(en_caption_convert_to_srt) | |
#save the caption to a file named Output.txt | |
text_file = open("cap.txt", "w") | |
text_file.write(en_caption_convert_to_srt) | |
text_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment