以下のコードを実行してyotubeから字幕情報をダウンロードします。
print(caption.generate_srt_captions())
エラー内容
KeyError Traceback (most recent call last) <ipython-input-18-3eaba33b685f> in <module>() ----> 1 print(caption.generate_srt_captions()) 1 frames /usr/local/lib/python3.7/dist-packages/pytube/captions.py in xml_caption_to_srt(self, xml_captions) 81 82 def __repr__(self): ---> 83 """Printable object representation.""" 84 return'<Caption lang="{s.name}" code="{s.code}">'.format(s=self) KeyError: 'start'
実行環境
pytube 9.2.3
Colaboratory
全コード
pip install pytube import os from pytube import YouTube video_link = 'https://youtu.be/54ndaG-gVgA?t=1' yt = YouTube(video_link) print(yt.title) print(yt.captions.all()) caption = yt.captions.get_by_language_code('a.ja') print(caption.xml_captions) print(caption.generate_srt_captions())
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。