@@ -67,6 +67,13 @@ def parse_top_result(data: JsonDict, search_result_types: list[str]) -> JsonDict
67
67
search_result ["title" ] = nav (data , TITLE_TEXT )
68
68
search_result ["author" ] = parse_song_artists_runs (nav (data , ["subtitle" , "runs" ])[2 :])
69
69
70
+ if result_type in ["episode" ]:
71
+ search_result ["videoId" ] = nav (data , [* THUMBNAIL_OVERLAY_NAVIGATION , * WATCH_VIDEO_ID ])
72
+ search_result ["videoType" ] = nav (data , [* THUMBNAIL_OVERLAY_NAVIGATION , * NAVIGATION_VIDEO_TYPE ])
73
+ runs = nav (data , SUBTITLE_RUNS )[2 :]
74
+ search_result ["date" ] = runs [0 ]["text" ]
75
+ search_result ["podcast" ] = parse_id_name (runs [2 ])
76
+
70
77
search_result ["thumbnails" ] = nav (data , THUMBNAILS , True )
71
78
return search_result
72
79
@@ -96,7 +103,10 @@ def parse_search_result(
96
103
iter (type for prefix , type in mapping .items () if browse_id .startswith (prefix )), None
97
104
)
98
105
else :
99
- result_type = "song" if video_type == "MUSIC_VIDEO_TYPE_ATV" else "video"
106
+ result_type = {
107
+ "MUSIC_VIDEO_TYPE_ATV" : "song" ,
108
+ "MUSIC_VIDEO_TYPE_PODCAST_EPISODE" : "episode" ,
109
+ }.get (video_type or "" , "video" )
100
110
101
111
search_result ["resultType" ] = result_type
102
112
@@ -191,12 +201,13 @@ def parse_search_result(
191
201
192
202
if result_type in ["episode" ]:
193
203
flex_item = get_flex_column_item (data , 1 )
194
- has_date = int (len (nav (flex_item , TEXT_RUNS )) > 1 )
204
+ runs = nav (flex_item , TEXT_RUNS )[default_offset :]
205
+ has_date = int (len (runs ) > 1 )
195
206
search_result ["live" ] = bool (nav (data , ["badges" , 0 , "liveBadgeRenderer" ], True ))
196
207
if has_date :
197
- search_result ["date" ] = nav ( flex_item , TEXT_RUN_TEXT )
208
+ search_result ["date" ] = runs [ 0 ][ "text" ]
198
209
199
- search_result ["podcast" ] = parse_id_name (nav ( flex_item , [ "text" , " runs" , has_date * 2 ]) )
210
+ search_result ["podcast" ] = parse_id_name (runs [ has_date * 2 ])
200
211
201
212
search_result ["thumbnails" ] = nav (data , THUMBNAILS , True )
202
213
0 commit comments