[youtube] Add view_count (Fixes #1781)
authorPhilipp Hagemeister <phihag@phihag.de>
Sun, 17 Nov 2013 10:06:16 +0000 (11:06 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sun, 17 Nov 2013 10:06:16 +0000 (11:06 +0100)
youtube_dl/extractor/youtube.py

index 8c0e6f2520e02e5d34a24f01a20637ea4a90a6f9..1aa5497408b8bf0833d329a725dd9de97785558e 100644 (file)
@@ -1301,6 +1301,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
             else:
                 raise ExtractorError(u'"token" parameter not in video info for unknown reason')
 
+        if 'view_count' in video_info:
+            view_count = int(video_info['view_count'][0])
+        else:
+            view_count = None
+
         # Check for "rental" videos
         if 'ypc_video_rental_bar_text' in video_info and 'author' not in video_info:
             raise ExtractorError(u'"rental" videos not supported')
@@ -1489,6 +1494,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
                 'age_limit':    18 if age_gate else 0,
                 'annotations':  video_annotations,
                 'webpage_url': 'https://www.youtube.com/watch?v=%s' % video_id,
+                'view_count': view_count,
             })
         return results