From 29eaa7a593c577be58ce7da661fc288aef359ec3 Mon Sep 17 00:00:00 2001 From: fischcode <82546407+fischcode@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:39:25 +0100 Subject: [PATCH] Add "type" attribute to library channels (#563) * Add "type" attribute to library channels YTMusic Library Channels list not only channels in the narrow sense but also artists publishing podcasts and episodes (e.g. The Offspring). To distinguish the two types of items, the json code contains a page_type attribute. This PR adds code to read the page_type attribute and, if present, add a "tyoe" item with a value of "channel" or "artist" to the artist dictionary object. --- ytmusicapi/parsers/library.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ytmusicapi/parsers/library.py b/ytmusicapi/parsers/library.py index 293f3c0..abb6ed5 100644 --- a/ytmusicapi/parsers/library.py +++ b/ytmusicapi/parsers/library.py @@ -14,6 +14,11 @@ def parse_artists(results, uploaded=False): artist = {} artist["browseId"] = nav(data, NAVIGATION_BROWSE_ID) artist["artist"] = get_item_text(data, 0) + page_type = nav(data, NAVIGATION_BROWSE + PAGE_TYPE, True) + if page_type == "MUSIC_PAGE_TYPE_USER_CHANNEL": + artist["type"] = "channel" + elif page_type == "MUSIC_PAGE_TYPE_ARTIST": + artist["type"] = "artist" parse_menu_playlists(data, artist) if uploaded: artist["songs"] = get_item_text(data, 1).split(" ")[0]