diff options
author | Sergey M․ <[email protected]> | 2019-06-07 23:13:33 +0700 |
---|---|---|
committer | Sergey M․ <[email protected]> | 2019-06-07 23:13:33 +0700 |
commit | bf3c9326634f4a918d0336b2c5f104ac492b5510 (patch) | |
tree | d471716a091bcb86348672a83dcbeeec8d87d21d | |
parent | 4c78c3d70086f9f8ea7ddcf8896065443c6dc37b (diff) | |
download | youtube-dl-bf3c9326634f4a918d0336b2c5f104ac492b5510.tar.gz youtube-dl-bf3c9326634f4a918d0336b2c5f104ac492b5510.zip |
[youtube] Fix average rating extraction (closes #21304)
-rw-r--r-- | youtube_dl/extractor/youtube.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 5f1957a59..963c73a2d 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -2224,6 +2224,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor): r'<[^>]+class=["\']watch-view-count[^>]+>\s*([\d,\s]+)', video_webpage, '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 video_subtitles = self.extract_subtitles(video_id, video_webpage) automatic_captions = self.extract_automatic_captions(video_id, video_webpage) @@ -2353,7 +2357,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor): 'view_count': view_count, 'like_count': like_count, 'dislike_count': dislike_count, - 'average_rating': float_or_none(video_info.get('avg_rating', [None])[0]), + 'average_rating': average_rating, 'formats': formats, 'is_live': is_live, 'start_time': start_time, |