get-pytube / pytube3

A lightweight, dependency-free Python 3 library (and command-line utility) for downloading YouTube Videos.
https://pytube3.readthedocs.io
Other
178 stars 55 forks source link

DeprecationWarning: Call to deprecated function get_by_language_code (This object can be treated as a dictionary, i.e. captions['en']) #116

Open gioggino opened 3 years ago

gioggino commented 3 years ago

When I try to download captions, I get this warning every time. That doesn't break the code but makes the console's output confusing for people that don't know.

Ksarqu commented 3 years ago

yeah me too

senkux commented 2 years ago

@Ksarqu @gioggino You can use caption = yt.captions['a.en'] instead of caption = yt.captions.get_by_language_code('en')

Code Example ---

from pytube import YouTube

url = "https://www.youtube.com/watch?v=ZtBzWUZbTvA"

yt = YouTube(url)
caption = yt.captions['a.en']
print(caption.xml_captions)

It will print the autogenerated caption in xml format The problem is causing in the xml_caption_to_srt method of Caption class.

yafethtb commented 11 months ago

I still got this deprecation message, unfortunately, because I following the documentation from Read The Docs https://pytube.io/en/latest/user/captions.html