pytube: [BUG] - Exception while accessing title
Before creating an issue
Please confirm that you are on the latest version of pytube by installing from the source.
You can do this by running python -m pip install git+https://github.com/pytube/pytube
.
Sometimes, the pypi library repository is not up to date, and your issue may have been fixed already!
Describe the bug When trying to access the title of a specific video, the error “Exception while accessing title” raises up. The error doesn’t raise up with another video.
To Reproduce
- Use the url “https://www.youtube.com/watch?v=d2-HtllN0NA” for this test
- Create a YouTube object with this url
- Try to retrieve the title of the video
Expected behavior The title is correctly retrieved
Output Traceback (most recent call last): File “/home/administrateur/PycharmProjects/youtube_downloader/venv/lib/python3.10/site-packages/pytube/main.py”, line 341, in title self._title = self.vid_info[‘videoDetails’][‘title’] KeyError: ‘videoDetails’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “/home/administrateur/PycharmProjects/youtube_downloader/main.py”, line 13, in <module> print(f"Le titre de la video est : {youtube_video.title}") File “/home/administrateur/PycharmProjects/youtube_downloader/venv/lib/python3.10/site-packages/pytube/main.py”, line 346, in title raise exceptions.PytubeError( pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=d2-HtllN0NA. Please file a bug report at https://github.com/pytube/pytube
System information Please provide the following information:
- Python version: 3.10.6
- Pytube version: 12.1.3
- Command used to install pytube: pip install git+https://github.com/pytube/pytube
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 10
- Comments: 18
Thank you very much! and to @JoaoEmanuell as well. Very cool.
That is one cool hint. Thanks a lot!
In case someone would be interested I pass my code (it’s about description and not title but the issue is the same).
I was able to solve it with
retryWithBackoff
approach.Just put https://pypi.org/project/backoff/ decorator on your function which requests it(if you can afford it and it’s idempotent, ofc) and works smoothly for me.
For those, who don’t have time to debug issues with this library.
Same issue here, when in debug mode you can wait and eventually it (sometimes) load the requested resource, but other times, it won’t even work there.
Same issue but each time.
Same issue, so no title at my outputs. Is there any way to bypsas this issue or we have to wait for a fix?
I’m having the same issue, only about 10% of the requests are going through.