Skip to content

Instantly share code, notes, and snippets.

@whoizit
Created July 10, 2021 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoizit/6bdc6337e7749d92cd377c24596088a7 to your computer and use it in GitHub Desktop.
Save whoizit/6bdc6337e7749d92cd377c24596088a7 to your computer and use it in GitHub Desktop.
get text from youtube video
#!/usr/bin/env python3
from youtube_transcript_api import YouTubeTranscriptApi as ytta
from youtube_transcript_api.formatters import TextFormatter as tf
import sys
yt_id = (
sys.argv[1]
.removeprefix('https://www.youtube.com/watch?v=')
.removeprefix('https://youtu.be/')
)
transcript = ytta.get_transcript(yt_id)
text = tf().format_transcript(transcript)
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment