From 2d30521ab9f535559dd208293982138516b88e8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Wed, 11 Feb 2015 18:39:31 +0100 Subject: [PATCH] [youtube] Extract average rating (closes #2362) --- youtube_dl/extractor/common.py | 1 + youtube_dl/extractor/youtube.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 8d71494b4..48742189a 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -157,6 +157,7 @@ class InfoExtractor(object): view_count: How many users have watched the video on the platform. like_count: Number of positive ratings of the video dislike_count: Number of negative ratings of the video + average_rating: Average rating give by users, the scale used depends on the webpage comment_count: Number of comments on the video comments: A list of comments, each with one or more of the following properties (all but one of text or html optional): diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 8b91fff18..35ef4c303 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -25,6 +25,7 @@ from ..compat import ( from ..utils import ( clean_html, ExtractorError, + float_or_none, get_element_by_attribute, get_element_by_id, int_or_none, @@ -1124,6 +1125,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor): 'view_count': view_count, 'like_count': like_count, 'dislike_count': dislike_count, + 'average_rating': float_or_none(video_info.get('avg_rating', [None])[0]), 'formats': formats, } -- 2.39.5