How to get the subtitles of a youtube video

Here is a script that let’s you get the subtitles of a youtube video. You just have to put the final part of the address of a youtube video in one line and you will have all the text downloaded in seconds.

# install in the cmd
# pip install youtube_transcript_api
from youtube_transcript_api import YouTubeTranscriptApi
import os

# put in the "" the final part of the video in the address bar of the browser
srt = YouTubeTranscriptApi.get_transcript("bD05uGo_sVI")
text = ""
with open("file.txt", "w") as file:
	for i in srt:
		text += i["text"] + "..."
	file.write(text)

os.startfile("file.txt")
How to get the subtitles from youtube videos with Python

How to download your videos from youtube with python. Do not use it to download videos that are not yours.


Subscribe to the newsletter for updates
Tkinter templates
My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts