Bug Description
When accessing length attribute of Youtube object, runs into error below that indicates lack of None handling:
File "/.venv/lib/python3.11/site-packages/pytube/__main__.py", line 383, in length return int(self.vid_info.get('videoDetails', {}).get('lengthSeconds')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
To Reproduce
Create a Youtube object with provided URL, and access video length. This will run into error above.
pytube.Youtube(video_url).length
Expected behavior
A number in seconds indicating video length is returned, if not available returns None
OutputFile "/.venv/lib/python3.11/site-packages/pytube/__main__.py", line 383, in length return int(self.vid_info.get('videoDetails', {}).get('lengthSeconds')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
System information
Please provide the following information:
Python version: Python 3.9.19 (This works on Python 3.9.6)
Pytube version: 15.0.0
Command used to install pytube: pip install pytube
Version: 15.0.0
Bug Description When accessing length attribute of Youtube object, runs into error below that indicates lack of None handling:
File "/.venv/lib/python3.11/site-packages/pytube/__main__.py", line 383, in length return int(self.vid_info.get('videoDetails', {}).get('lengthSeconds')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
To Reproduce Create a Youtube object with provided URL, and access video length. This will run into error above.
pytube.Youtube(video_url).length
Expected behavior A number in seconds indicating video length is returned, if not available returns None
Output
File "/.venv/lib/python3.11/site-packages/pytube/__main__.py", line 383, in length return int(self.vid_info.get('videoDetails', {}).get('lengthSeconds')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
System information Please provide the following information: