Skip to content

Commit

Permalink
add Null checks
Browse files Browse the repository at this point in the history
add Null checks
  • Loading branch information
AustinGitHub committed Jan 13, 2024
1 parent 55db498 commit 91254ce
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ytmusicapi/parsers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ def parse_top_result(data, search_result_types):

if result_type in ["song", "video", "album"]:
on_tap = data.get("onTap")
if on_tap:
search_result["videoId"] = nav(on_tap, WATCH_VIDEO_ID)
search_result["videoType"] = nav(on_tap, NAVIGATION_VIDEO_TYPE)
if on_tap is not None:
if "watchEndpoint" in on_tap:
if nav(on_tap, WATCH_VIDEO_ID) is not None:
search_result["videoId"] = nav(on_tap, WATCH_VIDEO_ID)
if "navigationEndpoint" in on_tap:
if nav(on_tap, NAVIGATION_VIDEO_TYPE) is not None:
search_result["videoType"] = nav(on_tap, NAVIGATION_VIDEO_TYPE)

search_result["title"] = nav(data, TITLE_TEXT)
runs = nav(data, ["subtitle", "runs"])
Expand Down

0 comments on commit 91254ce

Please sign in to comment.