get_home: remove "year" attribute from album results, parse podcasts … (#591)
* get_home: remove "year" attribute from album results, parse podcasts and episodes * search: make itemCount int cast error proof * fix None case for parse_album year * fix lint
This commit is contained in:
parent
fdc259461c
commit
33098ba69e
4 changed files with 18 additions and 11 deletions
|
|
@ -35,7 +35,6 @@ class BrowsingMixin(MixinProtocol):
|
|||
"contents": [
|
||||
{ //album result
|
||||
"title": "Sentiment",
|
||||
"year": "Said The Sky",
|
||||
"browseId": "MPREb_QtqXtd2xZMR",
|
||||
"thumbnails": [...]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from .podcasts import parse_episode, parse_podcast
|
||||
from .songs import *
|
||||
|
||||
|
||||
|
|
@ -30,11 +31,14 @@ def parse_mixed_content(rows):
|
|||
content = parse_related_artist(data)
|
||||
elif page_type == "MUSIC_PAGE_TYPE_PLAYLIST":
|
||||
content = parse_playlist(data)
|
||||
else:
|
||||
data = nav(result, [MRLIR], True)
|
||||
if not data:
|
||||
continue
|
||||
elif page_type == "MUSIC_PAGE_TYPE_PODCAST_SHOW_DETAIL_PAGE":
|
||||
content = parse_podcast(data)
|
||||
elif data := nav(result, [MRLIR], True):
|
||||
content = parse_song_flat(data)
|
||||
elif data := nav(result, [MMRIR], True):
|
||||
content = parse_episode(data)
|
||||
else:
|
||||
continue
|
||||
|
||||
contents.append(content)
|
||||
|
||||
|
|
@ -51,10 +55,9 @@ def parse_content_list(results, parse_func, key=MTRIR):
|
|||
|
||||
|
||||
def parse_album(result):
|
||||
return {
|
||||
album = {
|
||||
"title": nav(result, TITLE_TEXT),
|
||||
"type": nav(result, SUBTITLE),
|
||||
"year": nav(result, SUBTITLE2, True),
|
||||
"artists": [parse_id_name(x) for x in nav(result, ["subtitle", "runs"]) if "navigationEndpoint" in x],
|
||||
"browseId": nav(result, TITLE + NAVIGATION_BROWSE_ID),
|
||||
"audioPlaylistId": nav(result, THUMBNAIL_OVERLAY, True),
|
||||
|
|
@ -62,6 +65,11 @@ def parse_album(result):
|
|||
"isExplicit": nav(result, SUBTITLE_BADGE_LABEL, True) is not None,
|
||||
}
|
||||
|
||||
if (year := nav(result, SUBTITLE2, True)) and year.isnumeric():
|
||||
album["year"] = year
|
||||
|
||||
return album
|
||||
|
||||
|
||||
def parse_single(result):
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ def parse_podcast(data):
|
|||
"""Parses a single podcast under "Podcasts" on a channel page"""
|
||||
return {
|
||||
"title": nav(data, TITLE_TEXT),
|
||||
"channel": parse_id_name(nav(data, [*SUBTITLE_RUNS, 0])),
|
||||
"channel": parse_id_name(nav(data, [*SUBTITLE_RUNS, 0], True)),
|
||||
"browseId": nav(data, TITLE + NAVIGATION_BROWSE_ID),
|
||||
"podcastId": nav(data, THUMBNAIL_OVERLAY, True),
|
||||
"thumbnails": nav(data, THUMBNAIL_RENDERER),
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ def parse_search_result(data, search_result_types, result_type, category):
|
|||
elif result_type == "playlist":
|
||||
flex_item = get_flex_column_item(data, 1)["text"]["runs"]
|
||||
has_author = len(flex_item) == default_offset + 3
|
||||
search_result["itemCount"] = to_int(
|
||||
get_item_text(data, 1, default_offset + has_author * 2).split(" ")[0]
|
||||
)
|
||||
search_result["itemCount"] = get_item_text(data, 1, default_offset + has_author * 2).split(" ")[0]
|
||||
if search_result["itemCount"] and search_result["itemCount"].isnumeric():
|
||||
search_result["itemCount"] = to_int(search_result["itemCount"])
|
||||
search_result["author"] = None if not has_author else get_item_text(data, 1, default_offset)
|
||||
|
||||
elif result_type == "station":
|
||||
|
|
|
|||
Loading…
Reference in a new issue