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.
This commit is contained in:
fischcode 2024-03-13 19:39:25 +01:00 • committed by GitHub
commit 29eaa7a593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]