Describe the bug
I need to get URL to upload the video on AWS. The code is simplest as possible
yt = YouTube(video_url)
streams = yt.streams
The video that I want to download: http://youtube.com/watch?v=2lAe1cqCOXo
On the line where we get streams, it returns the error urllib.error.HTTPError: HTTP Error 404: Not Found
It's happening not always around once at 2-3 requests.
Full error list:
Internal Server Error: /api/external-video-upload/
Traceback (most recent call last):
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
return callback(request, *args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/alex/Developer/blossom-backend/blossom/recordings/views.py", line 819, in get
youtube_video_upload(video_url, recording)
File "/home/alex/Developer/blossom-backend/blossom/recordings/utils.py", line 791, in youtube_video_upload
streams = yt.streams
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 321, in streams
return StreamQuery(self.fmt_streams)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 214, in fmt_streams
if "adaptive_fmts" in self.player_config_args:
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 188, in player_config_args
self._player_config_args = self.vid_info
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 291, in vid_info
return dict(parse_qsl(self.vid_info_raw))
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 109, in vid_info_raw
self._vid_info_raw = request.get(self.vid_info_url)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 53, in get
response = _execute_request(url, headers=extra_headers, timeout=timeout)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
Internal Server Error: /api/external-video-upload/
Traceback (most recent call last):
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/sentry_sdk/integrations/django/views.py", line 67, in sentry_wrapped_callback
return callback(request, *args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/alex/Developer/blossom-backend/blossom/recordings/views.py", line 819, in get
youtube_video_upload(video_url, recording)
File "/home/alex/Developer/blossom-backend/blossom/recordings/utils.py", line 791, in youtube_video_upload
streams = yt.streams
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 321, in streams
return StreamQuery(self.fmt_streams)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 214, in fmt_streams
if "adaptive_fmts" in self.player_config_args:
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 188, in player_config_args
self._player_config_args = self.vid_info
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 291, in vid_info
return dict(parse_qsl(self.vid_info_raw))
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/__main__.py", line 109, in vid_info_raw
self._vid_info_raw = request.get(self.vid_info_url)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 53, in get
response = _execute_request(url, headers=extra_headers, timeout=timeout)
File "/home/alex/.local/share/virtualenvs/blossom-backend-FLIGhEMr/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/home/alex/.pyenv/versions/3.9.0/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
System information
- Python version 3.9
- Pytube version 10.9.3
bug