]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/ntvru.py
[ie/generic] Add `key_query` extractor-arg
[yt-dlp.git] / yt_dlp / extractor / ntvru.py
index c47d1dfa4d73d6bd31a377150ea92a3dbca75b38..1ab1be0f60f70690d0c26677be72bce50e259a8d 100644 (file)
@@ -1,6 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 from .common import InfoExtractor
 from ..utils import (
     int_or_none,
@@ -24,6 +21,7 @@ class NTVRuIE(InfoExtractor):
             'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 136,
+            'view_count': int,
         },
     }, {
         'url': 'http://www.ntv.ru/video/novosti/750370/',
@@ -35,7 +33,9 @@ class NTVRuIE(InfoExtractor):
             'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 172,
+            'view_count': int,
         },
+        'skip': '404 Not Found',
     }, {
         'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
         'md5': '82dbd49b38e3af1d00df16acbeab260c',
@@ -46,6 +46,7 @@ class NTVRuIE(InfoExtractor):
             'description': '«Сегодня». 21 марта 2014 года. 16:00',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 1496,
+            'view_count': int,
         },
     }, {
         'url': 'https://www.ntv.ru/kino/Koma_film/m70281/o336036/video/',
@@ -57,6 +58,7 @@ class NTVRuIE(InfoExtractor):
             'description': 'Остросюжетный фильм «Кома»',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 5592,
+            'view_count': int,
         },
     }, {
         'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
@@ -68,6 +70,7 @@ class NTVRuIE(InfoExtractor):
             'description': '«Дело врачей»: «Деревце жизни»',
             'thumbnail': r're:^http://.*\.jpg',
             'duration': 2590,
+            'view_count': int,
         },
     }, {
         # Schemeless file URL
@@ -76,7 +79,8 @@ class NTVRuIE(InfoExtractor):
     }]
 
     _VIDEO_ID_REGEXES = [
-        r'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)',
+        r'<meta property="og:url" content="https?://www\.ntv\.ru/video/(\d+)',
+        r'<meta property="og:video:(?:url|iframe)" content="https?://www\.ntv\.ru/embed/(\d+)',
         r'<video embed=[^>]+><id>(\d+)</id>',
         r'<video restriction[^>]+><key>(\d+)</key>',
     ]
@@ -98,7 +102,7 @@ def _real_extract(self, url):
                 self._VIDEO_ID_REGEXES, webpage, 'video id')
 
         player = self._download_xml(
-            'http://www.ntv.ru/vi%s/' % video_id,
+            f'http://www.ntv.ru/vi{video_id}/',
             video_id, 'Downloading video XML')
 
         title = strip_or_none(unescapeHTML(xpath_text(player, './data/title', 'title', fatal=True)))
@@ -107,7 +111,7 @@ def _real_extract(self, url):
 
         formats = []
         for format_id in ['', 'hi', 'webm']:
-            file_ = xpath_text(video, './%sfile' % format_id)
+            file_ = xpath_text(video, f'./{format_id}file')
             if not file_:
                 continue
             if file_.startswith('//'):
@@ -116,9 +120,16 @@ def _real_extract(self, url):
                 file_ = 'http://media.ntv.ru/vod/' + file_
             formats.append({
                 'url': file_,
-                'filesize': int_or_none(xpath_text(video, './%ssize' % format_id)),
+                'filesize': int_or_none(xpath_text(video, f'./{format_id}size')),
             })
-        self._sort_formats(formats)
+        hls_manifest = xpath_text(video, './playback/hls')
+        if hls_manifest:
+            formats.extend(self._extract_m3u8_formats(
+                hls_manifest, video_id, m3u8_id='hls', fatal=False))
+        dash_manifest = xpath_text(video, './playback/dash')
+        if dash_manifest:
+            formats.extend(self._extract_mpd_formats(
+                dash_manifest, video_id, mpd_id='dash', fatal=False))
 
         return {
             'id': xpath_text(video, './id'),