]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[dailymotion] Fix view count extraction
authorcazulu <jvlarapeinado@gmail.com>
Tue, 16 Feb 2016 09:45:53 +0000 (18:45 +0900)
committerSergey M․ <dstftw@gmail.com>
Thu, 18 Feb 2016 14:31:43 +0000 (20:31 +0600)
Fix view count parsing when the decimal marker is a whitespace, e.g. '101 101'

youtube_dl/extractor/dailymotion.py

index 7ae9f235987443a4a3f7ecc8cbdfef4297b37ae4..2e6226ea0774af2e636cbc4b4a4ca9f1ecb763a3 100644 (file)
@@ -122,10 +122,13 @@ class DailymotionIE(DailymotionBaseInfoExtractor):
         description = self._og_search_description(webpage) or self._html_search_meta(
             'description', webpage, 'description')
 
-        view_count = str_to_int(self._search_regex(
-            [r'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:(\d+)"',
-             r'video_views_count[^>]+>\s+([\d\.,]+)'],
-            webpage, 'view count', fatal=False))
+        view_count_str = self._search_regex(
+            (r'<meta[^>]+itemprop="interactionCount"[^>]+content="UserPlays:([\s\d,.]+)"',
+             r'video_views_count[^>]+>\s+([\s\d\,.]+)'),
+            webpage, 'view count', fatal=False)
+        if view_count_str:
+            view_count_str = re.sub(r'\s', '', view_count_str)
+        view_count = str_to_int(view_count_str)
         comment_count = int_or_none(self._search_regex(
             r'<meta[^>]+itemprop="interactionCount"[^>]+content="UserComments:(\d+)"',
             webpage, 'comment count', fatal=False))