From b4507be23bc87ef96d2c9e950fad4e0c6c59f40e Mon Sep 17 00:00:00 2001 From: sigma67 <16363825+sigma67@users.noreply.github.com> Date: Sun, 17 Aug 2025 08:45:58 +0200 Subject: [PATCH] add fallback for #799 (#800) --- ytmusicapi/parsers/search.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ytmusicapi/parsers/search.py b/ytmusicapi/parsers/search.py index b6352c7..f06281b 100644 --- a/ytmusicapi/parsers/search.py +++ b/ytmusicapi/parsers/search.py @@ -34,7 +34,9 @@ def get_search_result_type(result_type_local: str, result_types_local: list[str] def parse_top_result(data: JsonDict, search_result_types: list[str]) -> JsonDict: result_type = get_search_result_type(nav(data, SUBTITLE), search_result_types) - search_result = {"category": nav(data, CARD_SHELF_TITLE), "resultType": result_type} + # header element is missing in some edge cases (#799) + category = nav(data, CARD_SHELF_TITLE, True) or "Top result" + search_result = {"category": category, "resultType": result_type} if result_type == "artist": subscribers = nav(data, SUBTITLE2, True) if subscribers: