pytube: 404 on adaptive downloads
I’m getting a 404 from youtube when I attempt to download adaptive streams. Progressive is fine, but those aren’t the highest quality videos. Is there a work around for this one?
from pytube import YouTube
yt_video = YouTube("https://www.youtube.com/watch?v=xFSVoVOvaew")
yt_video.streams.filter(adaptive=True).order_by('resolution').first().download()
Returns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kaiser/tmp/pytube/pytube/streams.py", line 245, in download
bytes_remaining = self.filesize
File "/Users/kaiser/tmp/pytube/pytube/streams.py", line 156, in filesize
self._filesize = request.filesize(self.url)
File "/Users/kaiser/tmp/pytube/pytube/request.py", line 86, in filesize
return int(head(url)["content-length"])
File "/Users/kaiser/tmp/pytube/pytube/request.py", line 98, in head
response_headers = _execute_request(url, method="HEAD").info()
File "/Users/kaiser/tmp/pytube/pytube/request.py", line 27, in _execute_request
return urlopen(request) # nosec
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Users/kaiser/.pyenv/versions/3.8.2/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 37
This is still an issue, it should not be marked as stale.
nevermind it was 10.8.4 not 5 sorry about that
I have pytube version 10.9.3 but still error 404 is coming it was working 2-3 months ago but now its not working😕
Hey, it’s hard to say… I did nothing but just retry the bad case. It works for me! Anyway, thanks a lot for your help!
@XM-WANG this problem should be fixed as of November of last year. Check to make sure that you have the most recent version of pytube with the following code:
Currently, pytube is on version 10.6.1. If you’re using an older version, you can update with
python -m pip install --upgrade pytube
@tfdahlin Sure, here it goes
Code
Metadata for each video
@tfdahlin I tested your branch with some videos that were resulting in Error 404 and it worked very well