JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
https://pytubefix.readthedocs.io
MIT License
722 stars 100 forks source link

Playlist Obj difficulties with .last_updated attribute #307

Open wyattZarkLab opened 3 weeks ago

wyattZarkLab commented 3 weeks ago

:exclamation: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE :exclamation:

lack of information will lead to closure of the issue


Describe the bug Playlist Object .last_updated attribute attempts to access .sidebar_info array, throws index error on 0. Directly calling playlistObj.sidebar_info[0] does not throw error.


code that was used that resulted in the bug

>>> from pytubefix import Playlist
>>> a = Playlist('https://www.youtube.com/playlist?list=PLWOf5LXf8YNW6Xf6w4CT4KZ8lWU1nH9rz')
>>> a.last_updated
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pytubefix/contrib/playlist.py", line 383, in last_updated
    last_updated_text = self.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer'][
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
>>> a.sidebar_info # no issue
>>> b = a.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer']
>>> b = a.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer']['stats'][2]['runs'][1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> b = a.sidebar_info[0]['playlistSidebarPrimaryInfoRenderer']['stats'][2]['runs'][0]
'Updated today'
>>> 

Expected behavior A clear and concise description of what you expected to happen.

Use of Playlist Object .last_updated returns string or datetime value.


Screenshots If applicable, add screenshots to help explain your problem.


Desktop (please complete the following information):


Additional context Add any other context about the problem here.