Skip to content

Commit

Permalink
search: fix missing artists when filtering songs/videos
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Oct 5, 2024
1 parent 7d8a756 commit 41348ec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/mixins/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_search_filters(self, yt_auth):
query = "hip hop playlist"
results = yt_auth.search(query, filter="songs")
assert len(results) > 10
assert all(len(item["artists"]) > 0 for item in results)
assert all(item["resultType"] == "song" for item in results)
results = yt_auth.search(query, filter="videos")
assert len(results) > 10
Expand Down
3 changes: 2 additions & 1 deletion ytmusicapi/parsers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def parse_search_result(data, search_result_types, result_type, category):
search_result["year"] = None
flex_item = get_flex_column_item(data, 1)
runs = flex_item["text"]["runs"]
runs_offset = (len(runs[0]) == 1) * 2 # ignore the first run if it is a type specifier (like "Song")
# ignore the first run if it is a type specifier (like "Single" or "Album")
runs_offset = (len(runs[0]) == 1) * 2 * int(result_type == "album")
song_info = parse_song_runs(runs[runs_offset:])
search_result.update(song_info)

Expand Down

0 comments on commit 41348ec

Please sign in to comment.