]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[youtube] Extract average rating (closes #2362)
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Wed, 11 Feb 2015 17:39:31 +0000 (18:39 +0100)
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>
Wed, 11 Feb 2015 17:39:31 +0000 (18:39 +0100)
youtube_dl/extractor/common.py
youtube_dl/extractor/youtube.py

index 8d71494b4994dc2d8908acb430950e33b594fc32..48742189a12869a9d75d5c04d117873ab3bbc045 100644 (file)
@@ -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):
index 8b91fff18522763d667cd4538c47cce9a9253fbe..35ef4c30359cb70fa58b69eff16d75406190c5ed 100644 (file)
@@ -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,
         }