[ie/youtube] Fix heatmap
extraction (#8299)
Closes #8189 Authored by: bashonly
This commit is contained in:
parent
792f1e64f6
commit
03e85ea99d
1 changed files with 10 additions and 11 deletions
|
@ -3292,16 +3292,15 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
chapter_time, chapter_title, duration)
|
chapter_time, chapter_title, duration)
|
||||||
for contents in content_list)), [])
|
for contents in content_list)), [])
|
||||||
|
|
||||||
def _extract_heatmap_from_player_overlay(self, data):
|
def _extract_heatmap(self, data):
|
||||||
content_list = traverse_obj(data, (
|
return traverse_obj(data, (
|
||||||
'playerOverlays', 'playerOverlayRenderer', 'decoratedPlayerBarRenderer', 'decoratedPlayerBarRenderer', 'playerBar',
|
'frameworkUpdates', 'entityBatchUpdate', 'mutations',
|
||||||
'multiMarkersPlayerBarRenderer', 'markersMap', ..., 'value', 'heatmap', 'heatmapRenderer', 'heatMarkers', {list}))
|
lambda _, v: v['payload']['macroMarkersListEntity']['markersList']['markerType'] == 'MARKER_TYPE_HEATMAP',
|
||||||
return next(filter(None, (
|
'payload', 'macroMarkersListEntity', 'markersList', 'markers', ..., {
|
||||||
traverse_obj(contents, (..., 'heatMarkerRenderer', {
|
'start_time': ('startMillis', {functools.partial(float_or_none, scale=1000)}),
|
||||||
'start_time': ('timeRangeStartMillis', {functools.partial(float_or_none, scale=1000)}),
|
'end_time': {lambda x: (int(x['startMillis']) + int(x['durationMillis'])) / 1000},
|
||||||
'end_time': {lambda x: (x['timeRangeStartMillis'] + x['markerDurationMillis']) / 1000},
|
'value': ('intensityScoreNormalized', {float_or_none}),
|
||||||
'value': ('heatMarkerIntensityScoreNormalized', {float_or_none}),
|
})) or None
|
||||||
})) for contents in content_list)), None)
|
|
||||||
|
|
||||||
def _extract_comment(self, comment_renderer, parent=None):
|
def _extract_comment(self, comment_renderer, parent=None):
|
||||||
comment_id = comment_renderer.get('commentId')
|
comment_id = comment_renderer.get('commentId')
|
||||||
|
@ -4435,7 +4434,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
or self._extract_chapters_from_description(video_description, duration)
|
or self._extract_chapters_from_description(video_description, duration)
|
||||||
or None)
|
or None)
|
||||||
|
|
||||||
info['heatmap'] = self._extract_heatmap_from_player_overlay(initial_data)
|
info['heatmap'] = self._extract_heatmap(initial_data)
|
||||||
|
|
||||||
contents = traverse_obj(
|
contents = traverse_obj(
|
||||||
initial_data, ('contents', 'twoColumnWatchNextResults', 'results', 'results', 'contents'),
|
initial_data, ('contents', 'twoColumnWatchNextResults', 'results', 'results', 'contents'),
|
||||||
|
|
Loading…
Reference in a new issue