import pytube
yt = YouTube('https://www.youtube.com/watch?v=lW2pXu97Yvo')
yt.captions.all()
I'm trying this simple code and keep getting this:
Can somebody recommend a method of downloading YouTube subtitles?
import pytube
yt = YouTube('https://www.youtube.com/watch?v=lW2pXu97Yvo')
yt.captions.all()
I'm trying this simple code and keep getting this:
Can somebody recommend a method of downloading YouTube subtitles?
You never imported YouTube
. It's supposed to be:
from pytube3 import YouTube # for Python 3
from pytube import YouTube # for Python 2
yt = YouTube('https://www.youtube.com/watch?v=lW2pXu97Yvo')
yt.captions.all()
Use pytube3 instead, it has the same API but is Python3 only: https://github.com/hbmartin/pytube3