'Getting error code when trying to download using pytube
Not sure what it is, but its been driving me nuts and im such a newbie I tried so many things but im not sure what it means, ive tried installing and reinstalling pytube but nothing changed.
Here's my code
from pytube import YouTube
link = input("Enter in a link: ")
video = YouTube(link)
print(video.title)
print(video.streams.filter(progressive=True))
stream = video.streams.get_by_itag(22)
stream.download()
print("Video downloaded")
The entire error message:
Traceback (most recent call last):
- File "c:\PytubeDownloader\YoutubeDownloader2.py", line 5, in <module>
video = YouTube(link)
- File "C:\Python\lib\site-packages\pytube\__main__.py", line 91, in __init__
self.prefetch()
- File "C:\Python\lib\site-packages\pytube\__main__.py", line 181, in prefetch
self.vid_info_raw = request.get(self.vid_info_url)
- File "C:\Python\lib\site-packages\pytube\request.py", line 36, in get
return _execute_request(url).read().decode("utf-8")
- File "C:\Python\lib\site-packages\pytube\request.py", line 24, in _execute_request
return urlopen(request) # nosec
- File "C:\Python\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
- File "C:\Python\lib\urllib\request.py", line 525, in open
response = meth(req, response)
- File "C:\Python\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
- File "C:\Python\lib\urllib\request.py", line 557, in error
result = self._call_chain(*args)
- File "C:\Python\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
- File "C:\Python\lib\urllib\request.py", line 749, in http_error_302
return self.parent.open(new, timeout=req.timeout)
- File "C:\Python\lib\urllib\request.py", line 525, in open
response = meth(req, response)
- File "C:\Python\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
- File "C:\Python\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
- File "C:\Python\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
- File "C:\Python\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone
Ok so I did what was recommended in Pytube: urllib.error.HTTPError: HTTP Error 410: Gone and now im getting a completely different error
Traceback (most recent call last):
- File "c:\PytubeDownloader\YoutubeDownloader2.py", line 9, in print(video.streams.filter(progressive=True))
- File "C:\Python\lib\site-packages\pytube_main_.py", line 292, in streams return StreamQuery(self.fmt_streams)
- File "C:\Python\lib\site-packages\pytube_main_.py", line 184, in fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js)
- File "C:\Python\lib\site-packages\pytube\extract.py", line 409, in apply_signature cipher = Cipher(js=js)
- File "C:\Python\lib\site-packages\pytube\cipher.py", line 33, in init raise RegexMatchError(
- pytube.exceptions.RegexMatchError: init: could not find match for ^\w+\W
Solution 1:[1]
Experienced same error. In cipher.py
replace the regexs in pattern
in get_initial_function_name
with:
r'\bc\s*&&\s*d\.set\([^,]+\s*,\s*\([^)]*\)\s*\(\s*(?P<sig>[a-zA-Z0-9$]+)\('
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Aly Ahmed Aly |