diff --git a/tests/mixins/test_search.py b/tests/mixins/test_search.py index 8ee4b208..ab8745da 100644 --- a/tests/mixins/test_search.py +++ b/tests/mixins/test_search.py @@ -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 diff --git a/ytmusicapi/parsers/search.py b/ytmusicapi/parsers/search.py index bcceaafd..2facc0f1 100644 --- a/ytmusicapi/parsers/search.py +++ b/ytmusicapi/parsers/search.py @@ -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)