📜  如何下载 youtube 视频的字幕 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.485000             🧑  作者: Mango

代码示例1
# pip install youtube_transcript_api

from youtube_transcript_api import YouTubeTranscriptApi

video_link = 'https://www.youtube.com/watch?v=Vdj1TNWJAZ4&t=8s'

video_id = video_link.split('watch?v=')[1]

subtitle = YouTubeTranscriptApi.get_transcript(video_id=video_id, languages=['en'])

# you can do anything with downloaded caption.
# for example:
print(subtitle)