sns-sdks / python-youtube

A simple Python wrapper for YouTube Data API :sparkles: :cake: :sparkles: .
https://sns-sdks.github.io/python-youtube/
MIT License
304 stars 46 forks source link

No Filter Selected Error #156

Open axiinyaa opened 1 year ago

axiinyaa commented 1 year ago

Code:

        search_ : pyyoutube.SearchListResponse = youtube.search_by_keywords(q = content)
        tracks = []

        for result in list(search_.items):

            video : pyyoutube.VideoListResponse = youtube.get_video_by_id(video_id=result.id.videoId).items[0].snippet

            song_name = video.title
            artists = video.channelTitle
            url = video.thumbnails.standard.url

Traceback:

Traceback (most recent call last):
  File "C:\Python311\Lib\site-packages\interactions\client\models\command.py", line 907, in wrapper
    return await coro(self.extension, ctx, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Axolp\OneDrive\Documents\GitHub\JimBit\Commands\music.py", line 882, in autocomplete
    items = await self.load_spotify_search(text)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Axolp\OneDrive\Documents\GitHub\JimBit\Commands\music.py", line 337, in load_spotify_search
    video : pyyoutube.VideoListResponse = youtube.get_video_by_id(video_id=result.id.videoId).items[0].snippet
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\pyyoutube\api.py", line 2338, in get_video_by_id
    data = self._parse_response(resp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\pyyoutube\api.py", line 327, in _parse_response
    raise PyYouTubeException(response)
pyyoutube.error.PyYouTubeException: YouTubeException(status_code=400,message=No filter selected. Expected one of: id, myRating, chart)
Invalid Form Body

I don't know what i'm doing wrong here.

MerleLiuKun commented 1 year ago

May be the result.id.videoId give the None.

You can print the result to check this.