search: improve podcast and episode search
This commit is contained in:
parent
123eae7370
commit
be7a6090b0
3 changed files with 14 additions and 10 deletions
|
|
@ -82,3 +82,10 @@ def i18n(method):
|
|||
return method(self, *method_args, **method_kwargs)
|
||||
|
||||
return _impl
|
||||
|
||||
|
||||
def parse_id_name(sub_run):
|
||||
return {
|
||||
"id": nav(sub_run, NAVIGATION_BROWSE_ID, True),
|
||||
"name": nav(sub_run, ["text"], True),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from ._utils import *
|
||||
from .songs import *
|
||||
|
||||
|
||||
|
|
@ -64,13 +63,6 @@ def parse_album(result):
|
|||
}
|
||||
|
||||
|
||||
def parse_id_name(sub_run):
|
||||
return {
|
||||
"id": nav(sub_run, NAVIGATION_BROWSE_ID, True),
|
||||
"name": nav(sub_run, ["text"], True),
|
||||
}
|
||||
|
||||
|
||||
def parse_single(result):
|
||||
return {
|
||||
"title": nav(result, TITLE_TEXT),
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ def parse_search_result(data, search_result_types, result_type, category):
|
|||
search_result["releaseDate"] = runs[2]
|
||||
search_result["resultType"] = "album"
|
||||
|
||||
if result_type in ["song", "video"]:
|
||||
if result_type in ["song", "video", "episode"]:
|
||||
search_result["videoId"] = nav(
|
||||
data, [*PLAY_BUTTON, "playNavigationEndpoint", "watchEndpoint", "videoId"], True
|
||||
)
|
||||
|
|
@ -137,12 +137,17 @@ def parse_search_result(data, search_result_types, result_type, category):
|
|||
song_info = parse_song_runs(runs)
|
||||
search_result.update(song_info)
|
||||
|
||||
if result_type in ["artist", "album", "playlist", "profile"]:
|
||||
if result_type in ["artist", "album", "playlist", "profile", "podcast"]:
|
||||
search_result["browseId"] = nav(data, NAVIGATION_BROWSE_ID, True)
|
||||
|
||||
if result_type in ["song", "album"]:
|
||||
search_result["isExplicit"] = nav(data, BADGE_LABEL, True) is not None
|
||||
|
||||
if result_type in ["episode"]:
|
||||
flex_item = get_flex_column_item(data, 1)
|
||||
search_result["date"] = nav(flex_item, TEXT_RUN_TEXT)
|
||||
search_result["podcast"] = parse_id_name(nav(flex_item, ["text", "runs", 2]))
|
||||
|
||||
search_result["thumbnails"] = nav(data, THUMBNAILS, True)
|
||||
|
||||
return search_result
|
||||
|
|
|
|||
Loading…
Reference in a new issue