Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove offset + fix top result #517

Merged
merged 4 commits into from
Jan 14, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ytmusicapi/parsers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ def parse_top_result(data, search_result_types):
search_result["videoType"] = nav(on_tap, NAVIGATION_VIDEO_TYPE)

if result_type in ["song", "video", "album"]:
on_tap = data.get("onTap")
sigma67 marked this conversation as resolved.
Show resolved Hide resolved
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)
AustinGitHub marked this conversation as resolved.
Show resolved Hide resolved

search_result["title"] = nav(data, TITLE_TEXT)
runs = nav(data, ["subtitle", "runs"])[2:]
runs = nav(data, ["subtitle", "runs"])
sigma67 marked this conversation as resolved.
Show resolved Hide resolved
song_info = parse_song_runs(runs)
search_result.update(song_info)

Expand Down Expand Up @@ -125,7 +134,7 @@ def parse_search_result(data, search_result_types, result_type, category):
search_result["duration"] = None
search_result["year"] = None
flex_item = get_flex_column_item(data, 1)
runs = flex_item["text"]["runs"][default_offset:]
runs = flex_item["text"]["runs"]
sigma67 marked this conversation as resolved.
Show resolved Hide resolved
song_info = parse_song_runs(runs)
search_result.update(song_info)

Expand Down
Loading