pytube: [BUG] Empty streams for some videos
For some links, the streams
property is empty, and the get_audio_only()
method returns None. I’ve identified a few such links that seems to be reproducible. Here’s my test code that shows the problem:
from pytube import YouTube
FAILING = [
"https://www.youtube.com/watch?v=L6nrMAFCzhg",
"https://www.youtube.com/watch?v=T8de-31Hu7g",
"https://www.youtube.com/watch?v=Y08HWyVSMxg",
"https://www.youtube.com/watch?v=WchEW9LkK94",
]
OK = [
"https://www.youtube.com/watch?v=7lYMmW2kPpQ",
"https://www.youtube.com/watch?v=7eVQHt690nk",
"https://www.youtube.com/watch?v=4bscOLDng0o",
]
for fail in FAILING:
yt = YouTube(fail)
stream = yt.streams.get_audio_only()
# that's unexpected, stream shouldn't be None
assert stream is None
assert len(yt.streams) == 0
for ok in OK:
yt = YouTube(ok)
stream = yt.streams.get_audio_only()
# same code, different links - all good
assert stream is not None
assert len(yt.streams) > 0
I’ve tested on freshly created virtualenv and the newest pytube
. Same error on Windows and Ubuntu (WSL).
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 23
@KrishnarajT and @PC-02 I believe your problems are also fixed in the github repository, just not the pypi repository. You should also run python -m pip install git+https://github.com/nficano/pytube to install from source, and see if that fixes the problem for you.
@tfdahlin The links work now, looks like it was an issue caused by using 10.0.0. Thank you so much!
@tfdahlin yes, the links work perfectly fine now, I had noticed the latest version in the docs, but didnt think of installing from source. Thanks a ton!