alexmercerind / youtube-search-python

🔎 Search for YouTube videos, channels & playlists. Get 🎞 video & 📑 playlist info using link. Get search suggestions. WITHOUT YouTube Data API v3.
MIT License
735 stars 163 forks source link

Playlist class doesn't have a good error handling when Playlist doesn't have any videos #127

Closed Maple-Elter closed 2 years ago

Maple-Elter commented 3 years ago

When I try and use the Playlist function with an unlisted playlist from Youtube Music I get this output

Traceback (most recent call last):
  File "D:\Program Files\Python39\lib\threading.py", line 954, in _bootstrap_inner       
    self.run()
  File "D:\Program Files\Python39\lib\threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "c:\Users\Alucard\Desktop\ytalbumdl-source\ytalbumdl.py", line 245, in url_handler
    videos = Playlist(video_url)
  File "c:\Users\Alucard\Desktop\ytalbumdl-source\youtubesearchpython\extras.py", line 560, in __init__
    self.__playlist.sync_create()
  File "c:\Users\Alucard\Desktop\ytalbumdl-source\youtubesearchpython\core\playlist.py", line 34, in sync_create
    self.post_processing()
  File "c:\Users\Alucard\Desktop\ytalbumdl-source\youtubesearchpython\core\playlist.py", line 25, in post_processing
    self.__getComponents()
  File "c:\Users\Alucard\Desktop\ytalbumdl-source\youtubesearchpython\core\playlist.py", line 118, in __getComponents
    channelrenderer = self.responseSource["sidebar"]["playlistSidebarRenderer"]["items"][1]["playlistSidebarSecondaryInfoRenderer"]["videoOwner"]["videoOwnerRenderer"]
IndexError: list index out of range

support for music.youtube.com urls would be nice as well

Maple-Elter commented 2 years ago

For clarification of what's happening, if I take a playlist from yt music (e.g. https://music.youtube.com/playlist?list=OLAK5uy_k-u-6gWdaEocMirLVjRGxNV35mG-lgwxA) and change it to something like https://www.youtube.com/playlist?list=OLAK5uy_k-u-6gWdaEocMirLVjRGxNV35mG-lgwxA you get an unlisted playlist, but ysp can't seem to get the data from it

mytja commented 2 years ago

So, I dig a little bit into it. Here is what I found out.

1. Let's go manually to link you given to me.

It doesn't return a "videoRenderer", so our library is failing.

The title and description on this issue are completly invalid, but since it doesn't throw a proper error when nothing is found, I will rename this issue title & add proper error handling...

What takes YouTube Music support, I am not planning to add it any time soon. There is a well maintained library for YouTube Music for Python. You might need this.

Maple-Elter commented 2 years ago

This is weird because I get a full playlist

mytja commented 2 years ago

This is weird because I get a full playlist

Are you signed into YouTube in your browser?

Maple-Elter commented 2 years ago

yes, I'll try it without being signed in and trying it with a different account

Maple-Elter commented 2 years ago

image signed out and I can still access the playlist

mytja commented 2 years ago

Hmm. I am not quite sure what could be wrong. Maybe region blocking... I will test it in following week...

Maple-Elter commented 2 years ago

hmm ok

Maple-Elter commented 2 years ago

yeah it seems to be region locking, because if I try and access it with protonvpn in the netherlands it shows no available videos

Maple-Elter commented 2 years ago

I figured out the issue, all I had to do was comment out the channelrenderer references in playlist.py since I don't need channel info for my projects purposes and downgrade my version since using the code from the latest commit seems to throw another error for me