[youtube] Fix likes/dislike extraction
authorSergey M․ <dstftw@gmail.com>
Sun, 28 Jun 2015 18:48:06 +0000 (00:48 +0600)
committerSergey M․ <dstftw@gmail.com>
Sun, 28 Jun 2015 18:48:06 +0000 (00:48 +0600)
youtube_dl/extractor/youtube.py

index d9240ff02b5f6d5ba19350044022ae535443a599..8b43e274b73b1393305566a1e6a0a36f0d71551c 100644 (file)
@@ -29,6 +29,7 @@ from ..utils import (
     get_element_by_id,
     int_or_none,
     orderedSet,
+    str_to_int,
     unescapeHTML,
     unified_strdate,
     uppercase_escape,
@@ -1005,12 +1006,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
                 video_description = ''
 
         def _extract_count(count_name):
-            count = self._search_regex(
-                r'id="watch-%s"[^>]*>.*?([\d,]+)\s*</span>' % re.escape(count_name),
-                video_webpage, count_name, default=None)
-            if count is not None:
-                return int(count.replace(',', ''))
-            return None
+            return str_to_int(self._search_regex(
+                r'-%s-button[^>]+><span[^>]+class="yt-uix-button-content"[^>]*>([\d,]+)</span>'
+                % re.escape(count_name),
+                video_webpage, count_name, default=None))
+
         like_count = _extract_count('like')
         dislike_count = _extract_count('dislike')