Using The Python youtube-transcript-api
Used this to build GitHub - bramses/youtube-transcript-obsidian -- though these days I just use Whisper to transcribe my video files.
The easiest way to get a transcript for a given video is to execute:
(View Highlight)
from youtube_transcript_api import YouTubeTranscriptApi
YouTubeTranscriptApi.get_transcript(video_id)