pytube / pytube

A lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
https://pytube.io
The Unlicense
12.27k stars 2.52k forks source link

[BUG] pytube.exceptions.VideoUnavailable #1126

Open Nathan1258 opened 3 years ago

Nathan1258 commented 3 years ago

Describe the bug Occurs when a video on YouTube is not available to download/view. I am catching the exception:

try: yt = YouTube(link) except VideoUnavailable:

However it still throws as an error at runtime which crashes the program.

To Reproduce Downloading a video that is not available on YouTube (https://youtu.be/itBUkytySOg) for example. Even if you try to catch the exception, it does not work.

Expected behavior The program should catch the exception and dismiss it to allow it to give feedback that the video was not available.

Output Traceback (most recent call last): File "/Users/nathan/OneDrive/Projects/YTVideoDownloader.py", line 58, in <module> main() File "/Users/nathan/OneDrive/Projects/YTVideoDownloader.py", line 36, in main yt.streams.filter(file_extension='mp4').first().download() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytube/__main__.py", line 291, in streams self.check_availability() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pytube/__main__.py", line 227, in check_availability raise exceptions.VideoUnavailable(video_id=self.video_id) pytube.exceptions.VideoUnavailable: itBUkytySOg is unavailable

System information Please provide the following information:

github-actions[bot] commented 3 years ago

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

Lenochxd commented 2 years ago

Same problem. Any updates?

DavidBerdik commented 2 years ago

I am also encountering this issue.