[youtube] Fix average rating extraction (closes #21304)

This commit is contained in:
Sergey M․ 2019-06-07 23:13:33 +07:00
parent 4c78c3d700
commit bf3c932663
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -2224,6 +2224,10 @@ def _extract_count(count_name):
r'<[^>]+class=["\']watch-view-count[^>]+>\s*([\d,\s]+)', video_webpage, r'<[^>]+class=["\']watch-view-count[^>]+>\s*([\d,\s]+)', video_webpage,
'view count', default=None)) 'view count', default=None))
average_rating = (
float_or_none(video_details.get('averageRating'))
or try_get(video_info, lambda x: float_or_none(x['avg_rating'][0])))
# subtitles # subtitles
video_subtitles = self.extract_subtitles(video_id, video_webpage) video_subtitles = self.extract_subtitles(video_id, video_webpage)
automatic_captions = self.extract_automatic_captions(video_id, video_webpage) automatic_captions = self.extract_automatic_captions(video_id, video_webpage)
@ -2353,7 +2357,7 @@ def decrypt_sig(mobj):
'view_count': view_count, 'view_count': view_count,
'like_count': like_count, 'like_count': like_count,
'dislike_count': dislike_count, 'dislike_count': dislike_count,
'average_rating': float_or_none(video_info.get('avg_rating', [None])[0]), 'average_rating': average_rating,
'formats': formats, 'formats': formats,
'is_live': is_live, 'is_live': is_live,
'start_time': start_time, 'start_time': start_time,