search: fix missing artists when filtering songs/videos (#655)
* search: fix missing artists when filtering songs/videos * search: fix missing artists when filtering songs/videos
This commit is contained in:
parent
77e40b7f7d
commit
e995ae56ce
3 changed files with 5 additions and 2 deletions
|
|
@ -49,6 +49,7 @@ class TestSearch:
|
|||
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
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class Parser:
|
|||
@i18n
|
||||
def get_search_result_types(self):
|
||||
return [
|
||||
_("album"),
|
||||
_("artist"),
|
||||
_("playlist"),
|
||||
_("song"),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def get_search_result_type(result_type_local, result_types_local):
|
|||
if result_type_local not in result_types_local:
|
||||
result_type = "album"
|
||||
else:
|
||||
result_type = UNIQUE_RESULT_TYPES[result_types_local.index(result_type_local)]
|
||||
result_type = ALL_RESULT_TYPES[result_types_local.index(result_type_local)]
|
||||
|
||||
return result_type
|
||||
|
||||
|
|
@ -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 and runs[0]["text"].lower() in search_result_types) * 2
|
||||
song_info = parse_song_runs(runs[runs_offset:])
|
||||
search_result.update(song_info)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue