2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class TvigleIE(InfoExtractor):
15 IE_DESC = 'Интернет-телевидение Tvigle.ru'
16 _VALID_URL = r'http://(?:www\.)?tvigle\.ru/(?:[^/]+/)+(?P<display_id>[^/]+)/$'
20 'url': 'http://www.tvigle.ru/video/brat/',
21 'md5': 'ff4344a4894b0524441fb6f8218dc716',
27 'description': 'md5:d16ac7c0b47052ea51fddb92c4e413eb',
33 'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/',
34 'md5': 'd9012d7c7c598fe7a11d7fb46dc1f574',
38 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком',
39 'description': 'md5:027f7dc872948f14c96d19b4178428a4',
46 def _real_extract(self, url):
47 mobj = re.match(self._VALID_URL, url)
48 display_id = mobj.group('display_id')
50 webpage = self._download_webpage(url, display_id)
52 video_id = self._html_search_regex(
53 r'<li class="video-preview current_playing" id="(\d+)">', webpage, 'video id')
55 video_data = self._download_json(
56 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id)
58 item = video_data['playlist']['items'][0]
61 description = item['description']
62 thumbnail = item['thumbnail']
63 duration = float_or_none(item['durationMilliseconds'], 1000)
64 age_limit = str_to_int(item['ageRestrictions'])
67 for vcodec, fmts in item['videos'].items():
68 for quality, video_url in fmts.items():
71 'format_id': '%s-%s' % (vcodec, quality),
73 'height': int(quality[:-1]),
74 'filesize': item['video_files_size'][vcodec][quality],
76 self._sort_formats(formats)
80 'display_id': display_id,
82 'description': description,
83 'thumbnail': thumbnail,
85 'age_limit': age_limit,