fix #758
This commit is contained in:
parent
f59a1b5dfd
commit
2bd7982a5d
2 changed files with 4 additions and 0 deletions
|
|
@ -74,10 +74,12 @@ class TestSearch:
|
|||
query = "hip hop playlist"
|
||||
results = yt_auth.search(query, filter="songs")
|
||||
assert len(results) > 10
|
||||
assert all(item["views"] != "" for item in results)
|
||||
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
|
||||
assert all(item["views"] != "" for item in results)
|
||||
assert all(item["resultType"] == "video" for item in results)
|
||||
results = yt_auth.search(query, filter="albums", limit=40)
|
||||
assert len(results) > 20
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ def parse_search_result(data, api_search_result_types, result_type, category):
|
|||
search_result["year"] = None
|
||||
flex_item = get_flex_column_item(data, 1)
|
||||
runs = flex_item["text"]["runs"]
|
||||
if flex_item2 := get_flex_column_item(data, 2):
|
||||
runs.extend([{"text": ""}, *flex_item2["text"]["runs"]]) # first item is a dummy separator
|
||||
# ignore the first run if it is a type specifier (like "Single" or "Album")
|
||||
runs_offset = (len(runs[0]) == 1 and runs[0]["text"].lower() in api_search_result_types) * 2
|
||||
song_info = parse_song_runs(runs[runs_offset:])
|
||||
|
|
|
|||
Loading…
Reference in a new issue