parse_seach_result: add playlist id to album search (#586)

* parse_seach_result: add playlist id to album search

* fix docs

* add to top result

---------

Co-authored-by: sigma67 <sigma67.github@gmail.com>
This commit is contained in:
Jonathan Bell 2024-05-25 01:15:26 -07:00 • committed by GitHub
commit 1f4332a8a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View file

@ -83,8 +83,9 @@ class SearchMixin(MixinProtocol):
{
"category": "Albums",
"resultType": "album",
"browseId": "MPREb_9nqEki4ZDpp",
"title": "(What's The Story) Morning Glory? (Remastered)",
"browseId": "MPREb_IInSY5QXXrW",
"playlistId": "OLAK5uy_kunInnOpcKECWIBQGB0Qj6ZjquxDvfckg",
"title": "(What's The Story) Morning Glory?",
"type": "Album",
"artist": "Oasis",
"year": "1995",

View file

@ -46,6 +46,7 @@ def parse_top_result(data, search_result_types):
if result_type in ["album"]:
search_result["browseId"] = nav(data, TITLE + NAVIGATION_BROWSE_ID, True)
search_result["playlistId"] = nav(data, ["buttons", 0, "buttonRenderer", "command", *WATCH_PID], True)
if result_type in ["playlist"]:
search_result["playlistId"] = nav(data, MENU_PLAYLIST_ID)
@ -159,6 +160,13 @@ def parse_search_result(data, search_result_types, result_type, category):
if result_type in ["song", "album"]:
search_result["isExplicit"] = nav(data, BADGE_LABEL, True) is not None
if result_type in ["album"]:
search_result["playlistId"] = nav(
data,
[*PLAY_BUTTON, "playNavigationEndpoint", "watchEndpoint", "playlistId"],
True,
)
if result_type in ["episode"]:
flex_item = get_flex_column_item(data, 1)
has_date = int(len(nav(flex_item, TEXT_RUNS)) > 1)