2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class NTVIE(InfoExtractor):
14 _VALID_URL = r'http://(?:www\.)?ntv\.ru/(?P<id>.+)'
18 'url': 'http://www.ntv.ru/novosti/863142/',
22 'title': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
23 'description': 'Командующий Черноморским флотом провел переговоры в штабе ВМС Украины',
28 'skip_download': True,
32 'url': 'http://www.ntv.ru/video/novosti/750370/',
36 'title': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
37 'description': 'Родные пассажиров пропавшего Boeing не верят в трагический исход',
42 'skip_download': True,
46 'url': 'http://www.ntv.ru/peredacha/segodnya/m23700/o232416',
50 'title': '«Сегодня». 21 марта 2014 года. 16:00 ',
51 'description': '«Сегодня». 21 марта 2014 года. 16:00 ',
56 'skip_download': True,
60 'url': 'http://www.ntv.ru/kino/Koma_film',
64 'title': 'Остросюжетный фильм «Кома»
\97 4 апреля вечером на НТВ',
65 'description': 'Остросюжетный фильм «Кома»
\97 4 апреля вечером на НТВ',
70 'skip_download': True,
74 'url': 'http://www.ntv.ru/serial/Delo_vrachey/m31760/o233916/',
78 'title': '«Дело врачей»: «Деревце жизни»',
79 'description': '«Дело врачей»: «Деревце жизни»',
84 'skip_download': True,
90 r'<meta property="og:url" content="http://www\.ntv\.ru/video/(\d+)',
91 r'<video embed=[^>]+><id>(\d+)</id>',
92 r'<video restriction[^>]+><key>(\d+)</key>'
95 def _real_extract(self, url):
96 mobj = re.match(self._VALID_URL, url)
97 video_id = mobj.group('id')
99 page = self._download_webpage(url, video_id, 'Downloading page')
101 def extract(patterns, name, page, fatal=False):
102 for pattern in patterns:
103 mobj = re.search(pattern, page)
107 raise RegexNotFoundError(u'Unable to extract %s' % name)
110 video_id = extract(self._VIDEO_ID_REGEXES, 'video id', page, fatal=True)
112 player = self._download_xml('http://www.ntv.ru/vi%s/' % video_id, video_id, 'Downloading video XML')
113 title = unescapeHTML(player.find('./data/title').text)
114 description = unescapeHTML(player.find('./data/description').text)
116 video = player.find('./data/video')
117 video_id = video.find('./id').text
118 thumbnail = video.find('./splash').text
119 duration = int(video.find('./totaltime').text)
120 view_count = int(video.find('./views').text)
121 puid22 = video.find('./puid22').text
129 for format_id in ['', 'hi', 'webm']:
130 file = video.find('./%sfile' % format_id)
133 size = video.find('./%ssize' % format_id)
134 app = apps[puid22] if puid22 in apps else apps['4']
136 'url': 'rtmp://media.ntv.ru/%s' % app,
138 'play_path': file.text,
140 'player_url': 'http://www.ntv.ru/swf/vps1.swf?update=20131128',
141 'page_url': 'http://www.ntv.ru',
142 'flash_ver': 'LNX 11,2,202,341',
145 'filesize': int(size.text),
147 self._sort_formats(formats)
152 'description': description,
153 'thumbnail': thumbnail,
154 'duration': duration,
155 'view_count': view_count,