I'm working on a Python YouTube downloader, a very simple task. I used pytube for a while and never encountered this error. My code is the following:
from pytube import YouTube
import pytube
yt_title = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').title
ytd = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').streams.first().download()
The error message I get is:
Traceback (most recent call last):
File ".\test.py", line 5, in <module>
ytd = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').streams.first().download()
AttributeError: 'NoneType' object has no attribute 'download'
These are the especifications:
Name: pytube
Version: 10.0.0
Summary: Python 3 library for downloading YouTube Videos.
Home-page: https://github.com/nficano/pytube
Author: Nick Ficano, Harold Martin
Author-email: [email protected], [email protected]
License: MIT
Location: 'location of the package'
Requires: typing-extensions
Required-by:
The video I'm using is: https://www.youtube.com/watch?v=ZjDZrReZ4EI
Something that I realized is that some videos that I was able to download a few hours before now I cannot. I just uninstalled pytube and installed pytube3. But now I get the following error:
pytube.exceptions.RegexMatchError: get_ytplayer_config: could not find match
for config_patterns
It doesn't let me download any video.
first()givesNoneand you can try to doNone.download(). You should firts getfirst()and check if it is notNonebefore you use `download()