Created
July 10, 2021 06:12
-
-
Save whoizit/6bdc6337e7749d92cd377c24596088a7 to your computer and use it in GitHub Desktop.
get text from youtube 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
#!/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