Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 404 exception using pytube with Python 3.8.5 #1065

Closed
haimavni opened this issue Jul 22, 2021 · 23 comments
Closed

[BUG] 404 exception using pytube with Python 3.8.5 #1065

haimavni opened this issue Jul 22, 2021 · 23 comments

Comments

@haimavni
Copy link

I am using the latest version
pytube @ git+https://github.com/pytube/pytube@10989d2b7a5c1825958904638932c0a3d8147d71

Describe the bug
I can create the YouTube object. However, when I try to access any of its properties an exception occurs.

To Reproduce
This is the code that demonstrates the bug:

from pytube import YouTube
yt = YouTube('https://youtu.be/2lAe1cqCOXo')
print(yt.title)
print(yt.thumbnail_url)

Expected behavior
I expect the title and thumbnail_url properties to be displayed. Instead I see an exception.

Output
If pytube raises an exception, please provide the full traceback for the exception:
Traceback (most recent call last):
File "try_pytube.py", line 3, in
print(yt.title)
File "/usr/local/lib/python3.8/dist-packages/pytube/main.py", line 366, in title
self._title = self.player_response['videoDetails']['title']
File "/usr/local/lib/python3.8/dist-packages/pytube/main.py", line 168, in player_response
if isinstance(self.player_config_args["player_response"], str):
File "/usr/local/lib/python3.8/dist-packages/pytube/main.py", line 188, in player_config_args
self._player_config_args = self.vid_info
File "/usr/local/lib/python3.8/dist-packages/pytube/main.py", line 291, in vid_info
return dict(parse_qsl(self.vid_info_raw))
File "/usr/local/lib/python3.8/dist-packages/pytube/main.py", line 109, in vid_info_raw
self._vid_info_raw = request.get(self.vid_info_url)
File "/usr/local/lib/python3.8/dist-packages/pytube/request.py", line 53, in get
response = _execute_request(url, headers=extra_headers, timeout=timeout)
File "/usr/local/lib/python3.8/dist-packages/pytube/request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/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

System information
Please provide the following information:

  • Python version (run python --version):
  • Python 3.8.5
  • Pytube version (run print(pytube.__version__) in python):
  • 10.9.3
  • Command used to install pytube:
  • python -m pip install git+https://github.com/pytube/pytube
@haimavni haimavni added the bug label Jul 22, 2021
@github-actions
Copy link

Thank you for contributing to PyTube. Please remember to reference Contributing.md

@TutorialDoctor
Copy link

I am using the latest version
pytube @ git+https://github.com/pytube/pytube@10989d2b7a5c1825958904638932c0a3d8147d71

Describe the bug

Getting a 404 when attempting to download a youtube video. It was working last week I'm sure.

To Reproduce

This is the code that demonstrates the bug:

from pytube import YouTube
YouTube('https://www.youtube.com/watch?v=kLTN4IEYltM').streams.first().download()

Expected behavior

Vide should be downloaded

Output

If pytube raises an exception, please provide the full traceback for the exception:

Traceback (most recent call last):
  File "/Users/RamonSuthers/Documents/DEVELOPER/Python/Flask_Apps/MY FLASK APPS/COMPLETED/youtube_downloader/download.py", line 6, in <module>
    YouTube('https://www.youtube.com/watch?v=kLTN4IEYltM').streams.first().download()
  File "/usr/local/lib/python3.9/site-packages/pytube/__main__.py", line 321, in streams
    return StreamQuery(self.fmt_streams)
  File "/usr/local/lib/python3.9/site-packages/pytube/__main__.py", line 214, in fmt_streams
    if "adaptive_fmts" in self.player_config_args:
  File "/usr/local/lib/python3.9/site-packages/pytube/__main__.py", line 188, in player_config_args
    self._player_config_args = self.vid_info
  File "/usr/local/lib/python3.9/site-packages/pytube/__main__.py", line 291, in vid_info
    return dict(parse_qsl(self.vid_info_raw))
  File "/usr/local/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 "/usr/local/lib/python3.9/site-packages/pytube/request.py", line 53, in get
    response = _execute_request(url, headers=extra_headers, timeout=timeout)
  File "/usr/local/lib/python3.9/site-packages/pytube/request.py", line 37, in _execute_request
    return urlopen(request, timeout=timeout)  # nosec
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.9/3.9.1_5/Frameworks/Python.framework/Versions/3.9/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
Please provide the following information:

Python version (run python --version):

Python 3.9.1

Pytube version (run print(pytube.version) in python):

10.9.3

Command used to install pytube:
pip3 install pytube

@fundamentalista
Copy link

fundamentalista commented Jul 22, 2021

since yesterday i have same problem..

@chudleycannon
Copy link

Also getting same issue with python 3.8,.8

@klcstaysbusy
Copy link

Same bug as of today, 100% failing, tried upgrading from python 3.8 to 3.9 only after pulling 10.9.3+Py3.8, same issue when using Py3.9+10.9.3.

Yesterday their was taddle-tail hints of failure where the first, or second attempt at pulling a video would fail, whereist usually on the second/third try it went through.

These same symptoms have occured in this pattern in the past before becoming fully inoperable, else I'm sure the fix is being worked on in a near future update.

@JacquesJacob
Copy link

same issue here...

@Cedric-Chen
Copy link

same issue~

@dragonwu0919
Copy link

same issue here

@KyleRusscher
Copy link

Also having this issue

@cdelaof26
Copy link

I think it might be a YouTube side-server change, I got same results with pytube 10.9.3, 10.8.2 and ssuwani's fork.

Python 3.9.4 on ARM64 Darwin

@glee1228
Copy link

same issue

@sirodus
Copy link

sirodus commented Jul 23, 2021

Request like this works as expected:

POST /youtubei/v1/player HTTP/1.1
Host: www.youtube.com
X-Goog-Api-Key: AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8

{"context":{"client":{"clientName":"ANDROID","clientVersion":"16.05"}},
"videoId":"kLTN4IEYltM"}

How to use it?
I use pytube in my project to download many videos a day from multiple channels. I need this very much today, please give some clue, I don't know the pytube very well and I've been working on it since morning.

@johngrindall
Copy link

I am having the same exact issue, running on pytube 10.8.5 and Python 3.9.1. I recall this same issue cropping up about a month ago, the problem likely being a server-side change on YouTube's end.

@ebrahimMaher
Copy link

same issue here, anyone got a solution?

@rishabh3354
Copy link

can anybody tell me when it is going to fix..?

@axornet
Copy link

axornet commented Jul 23, 2021

same issue

@Eolien55
Copy link

same issue here

@Mahmoudgarwallane
Copy link

same issue with python 3.6

@elyas1877
Copy link

same issue

@glubsy
Copy link
Contributor

glubsy commented Jul 23, 2021

Stop spamming "same" here please. This does not add anything of value but useless noise.

@tfdahlin
Copy link
Collaborator

Closing because this is a duplicate.

@tfdahlin
Copy link
Collaborator

@89z There are 5 issues that are all about 404 errors being returned by the get_video_info url

See: #1065, #1064, #1062, #1061, #1060

I close new issues in favor of older ones, unless the quality of information in a newer issues is drastically higher than an older one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests