[mtg] Improve view count extraction
authorSergey M․ <dstftw@gmail.com>
Tue, 16 Aug 2016 17:32:28 +0000 (00:32 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 16 Aug 2016 17:32:28 +0000 (00:32 +0700)
youtube_dl/extractor/tvplay.py

index c8ec2465c84eb8f57cb8c90fc9e58973c59029ae..4186e82db170300c6addeb0d0054c75b3d512e48 100644 (file)
@@ -15,6 +15,7 @@ from ..utils import (
     int_or_none,
     parse_iso8601,
     qualities,
+    try_get,
     update_url_query,
 )
 
@@ -203,6 +204,11 @@ class TVPlayIE(InfoExtractor):
             'url': 'http://tvplay.skaties.lv/parraides/vinas-melo-labak/418113?autostart=true',
             'only_matching': True,
         },
+        {
+            # views is null
+            'url': 'http://tvplay.skaties.lv/parraides/tv3-zinas/760183',
+            'only_matching': True,
+        },
         {
             'url': 'http://tv3play.tv3.ee/sisu/kodu-keset-linna/238551?autostart=true',
             'only_matching': True,
@@ -306,7 +312,7 @@ class TVPlayIE(InfoExtractor):
             'season_number': season_number,
             'duration': int_or_none(video.get('duration')),
             'timestamp': parse_iso8601(video.get('created_at')),
-            'view_count': int_or_none(video.get('views', {}).get('total')),
+            'view_count': try_get(video, lambda x: x['views']['total'], int),
             'age_limit': int_or_none(video.get('age_limit', 0)),
             'formats': formats,
             'subtitles': subtitles,