sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.71k stars 194 forks source link

get_episodes_playlist #531

Closed jstilwell closed 6 months ago

jstilwell commented 8 months ago

Hello, first of all, thank you for your work on this API. It's very much appreciated!

I am running into an issue that I'm not sure is PIBKAC, a bug, or a use case that just isn't valid. My oauth.json looks valid. I followed the steps in the documentation to generate it.

Here is my code, via a Python 3.11 interpreter, which is fairly simple:

from ytmusicapi import YTMusic
ytmusic = YTMusic("oauth.json")

# Get latest podcasts from playlist
podcasts = ytmusic.get_playlist(playlistId='RDPN', limit=100, related=False, suggestions_limit=0)

# List each podcast
for podcast in podcasts['tracks']:
    print(podcast['title'])

I retrieved the playlistId in the following steps:

The error I'm receiving when I execute the script:

Traceback (most recent call last):
  File "D:\code-projects\ytmusic-grabber\main.py", line 5, in <module>
    podcasts = ytmusic.get_playlist(playlistId='RDPN', limit=100, related=False, suggestions_limit=0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\code-projects\ytmusic-grabber\.venv\Lib\site-packages\ytmusicapi\mixins\playlists.py", line 109, in get_playlist
    results = nav(response, SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + ["musicPlaylistShelfRenderer"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\code-projects\ytmusic-grabber\.venv\Lib\site-packages\ytmusicapi\navigation.py", line 103, in nav
    raise err
  File "D:\code-projects\ytmusic-grabber\.venv\Lib\site-packages\ytmusicapi\navigation.py", line 97, in nav
    root = root[k]

I've checked the documentation and as far as I can tell, this should work. Am I missing something that is obvious?

sigma67 commented 8 months ago

this is not supported yet, see also #415

I assume you have subscribed to some podcasts? I'm not seeing this playlist in my podcasts library

jstilwell commented 8 months ago

this is not supported yet, see also #415

I assume you have subscribed to some podcasts? I'm not seeing this playlist in my podcasts library

Oh, yes, my apologies. I should have thought to add that to my steps to replicate. I am subscribed to a couple dozen podcasts, and also I'm a YouTube Premium subscriber. I'm not sure if that makes a difference.

So, when I subscribe to podcasts and then click on Library, I have an "auto-playlist" that is generated by YouTube called "New Episodes" that is automatically populated with the last 100 episodes of my subscriptions.

image

When I click on the button for that playlist, I am redirected to: https://music.youtube.com/playlist?list=RDPN

I would expect that if I'm using an authorized account, I should be able to retrieve the items from that playlist via YTMusic.get_playlist.

The interesting thing that I've just discovered is that if I use the playlist ID "LM" for the "Liked Music" auto-generated playlist, the code functions perfectly. So the payload for "RDPN" must differ enough to warrant a YTMusic.get_podcast_playlist function, which is odd. I'm not sure why that would be the case. Podcasts and Music typically carry the same kinds of metadata.

sigma67 commented 8 months ago

I just added the first podcast from your screenshot and the RDPN playlist showed up immediately.

It seems it's a mix of the playlist view and the podcast view, so it'll require a new endpoint