Skip to content

Commit 1f4332a

Browse files
parse_seach_result: add playlist id to album search (sigma67#586)
* parse_seach_result: add playlist id to album search * fix docs * add to top result --------- Co-authored-by: sigma67 <[email protected]>
1 parent 0cf0883 commit 1f4332a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

ytmusicapi/mixins/search.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ def search(
8383
{
8484
"category": "Albums",
8585
"resultType": "album",
86-
"browseId": "MPREb_9nqEki4ZDpp",
87-
"title": "(What's The Story) Morning Glory? (Remastered)",
86+
"browseId": "MPREb_IInSY5QXXrW",
87+
"playlistId": "OLAK5uy_kunInnOpcKECWIBQGB0Qj6ZjquxDvfckg",
88+
"title": "(What's The Story) Morning Glory?",
8889
"type": "Album",
8990
"artist": "Oasis",
9091
"year": "1995",

ytmusicapi/parsers/search.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def parse_top_result(data, search_result_types):
4646

4747
if result_type in ["album"]:
4848
search_result["browseId"] = nav(data, TITLE + NAVIGATION_BROWSE_ID, True)
49+
search_result["playlistId"] = nav(data, ["buttons", 0, "buttonRenderer", "command", *WATCH_PID], True)
4950

5051
if result_type in ["playlist"]:
5152
search_result["playlistId"] = nav(data, MENU_PLAYLIST_ID)
@@ -159,6 +160,13 @@ def parse_search_result(data, search_result_types, result_type, category):
159160
if result_type in ["song", "album"]:
160161
search_result["isExplicit"] = nav(data, BADGE_LABEL, True) is not None
161162

163+
if result_type in ["album"]:
164+
search_result["playlistId"] = nav(
165+
data,
166+
[*PLAY_BUTTON, "playNavigationEndpoint", "watchEndpoint", "playlistId"],
167+
True,
168+
)
169+
162170
if result_type in ["episode"]:
163171
flex_item = get_flex_column_item(data, 1)
164172
has_date = int(len(nav(flex_item, TEXT_RUNS)) > 1)

0 commit comments

Comments
 (0)