1

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.

2
  • 1
    errors means that first() gives None and you can try to do None.download(). You should firts get first() and check if it is not None before you use `download() Commented Dec 9, 2020 at 22:54
  • 1
    if you can't download some videos then you should check in web brower if they still exist on YouTube - maybe they were removed. OR youtube recognized that it is script and block you as a bot/spamer/hacker Commented Dec 9, 2020 at 22:57

1 Answer 1

1

You will have to uninstall pytube and install pytube3 using pip. If it does not work then print streams and see if you are getting streams

yt = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI')
print(yt.streams)
Sign up to request clarification or add additional context in comments.

2 Comments

I just uninstalled pytube and installed pytube3. When i try to running it it gives me the following error: pytube.exceptions.RegexMatchError: get_ytplayer_config: could not find match for config_patterns
github.com/nficano/pytube/issues/614#issuecomment-724326141 You can try this one, btw pytube version 10.1.0 solves the problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.