get_home: parse recommended channels (#807)

Handle channel links in `parse_mixed_content`:

```diff
[
  {
    "title": "Channels you may like",
    "contents": [
-     None
+     {
+       "title": "MTV UK",
+       "browseId": "UCuwUfM8E79h2sqp34Fut6kw",
+       "subscribers": "2.32M",
+       "thumbnails": [...]
+     }
```
This commit is contained in:
Solomon 2025-08-26 11:09:10 +00:00 • committed by GitHub
commit c33d4cc64e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -13,7 +13,7 @@ class TestBrowsing:
def test_get_home(self, yt, yt_auth):
result = yt.get_home()
assert len(result) >= 2
result = yt_auth.get_home(limit=15)
result = yt_auth.get_home(limit=20)
assert len(result) >= 15
assert all(
# ensure we aren't parsing specifiers like "Song" as artist names
@ -25,6 +25,10 @@ class TestBrowsing:
if item and len(item.get("artists", [])) > 1
]
)
assert all(
# ensure all links are supported by parse_mixed_content
[item is not None for section in result for item in section["contents"]]
)
def test_get_artist(self, yt):
results = yt.get_artist("MPLAUCmMUZbaYdNH0bEd1PAlAqsA")

View file

@ -34,7 +34,7 @@ def parse_mixed_content(
content = parse_song(data)
elif page_type == "MUSIC_PAGE_TYPE_ALBUM":
content = parse_album(data)
elif page_type == "MUSIC_PAGE_TYPE_ARTIST":
elif page_type in ["MUSIC_PAGE_TYPE_ARTIST", "MUSIC_PAGE_TYPE_USER_CHANNEL"]:
content = parse_related_artist(data)
elif page_type == "MUSIC_PAGE_TYPE_PLAYLIST":
content = parse_playlist(data)