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.
OutputTraceback (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:
Python version: 3.9.4
Pytube version: 11.0.1
Command used to install pytube: pip3 install pytube and python -m pip install git+https://github.com/pytube/pytube
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:
pip3 install pytube
andpython -m pip install git+https://github.com/pytube/pytube