2 from __future__ import unicode_literals
6 from .common import InfoExtractor
9 class NewstubeIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?newstube\.ru/media/(?P<id>.+)'
12 'url': 'http://newstube.ru/media/na-korable-progress-prodolzhaetsya-testirovanie-sistemy-kurs',
14 'id': 'd156a237-a6e9-4111-a682-039995f721f1',
16 'title': 'На корабле «Прогресс» продолжается тестирование системы «Курс»',
17 'description': 'md5:d0cbe7b4a6f600552617e48548d5dc77',
22 'skip_download': True,
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 video_id = mobj.group('id')
30 page = self._download_webpage(url, video_id, 'Downloading page')
32 video_guid = self._html_search_regex(
33 r'<meta property="og:video" content="https?://(?:www\.)?newstube\.ru/freshplayer\.swf\?guid=(?P<guid>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
36 player = self._download_xml(
37 'http://p.newstube.ru/v2/player.asmx/GetAutoPlayInfo6?state=&url=%s&sessionId=&id=%s&placement=profile&location=n2' % (url, video_guid),
38 video_guid, 'Downloading player XML')
41 return s.replace('/', '/%(ns)s') % {'ns': '{http://app1.newstube.ru/N2SiteWS/player.asmx}'}
43 session_id = player.find(ns('./SessionId')).text
44 media_info = player.find(ns('./Medias/MediaInfo'))
45 title = media_info.find(ns('./Name')).text
46 description = self._og_search_description(page)
47 thumbnail = media_info.find(ns('./KeyFrame')).text
48 duration = int(media_info.find(ns('./Duration')).text) / 1000.0
52 for stream_info in media_info.findall(ns('./Streams/StreamInfo')):
53 media_location = stream_info.find(ns('./MediaLocation'))
54 if media_location is None:
57 server = media_location.find(ns('./Server')).text
58 app = media_location.find(ns('./App')).text
59 media_id = stream_info.find(ns('./Id')).text
60 quality_id = stream_info.find(ns('./QualityId')).text
61 name = stream_info.find(ns('./Name')).text
62 width = int(stream_info.find(ns('./Width')).text)
63 height = int(stream_info.find(ns('./Height')).text)
66 'url': 'rtmp://%s/%s' % (server, app),
68 'play_path': '01/%s' % video_guid.upper(),
69 'rtmp_conn': ['S:%s' % session_id, 'S:%s' % media_id, 'S:n2'],
72 'format_id': quality_id,
78 self._sort_formats(formats)
83 'description': description,
84 'thumbnail': thumbnail,