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-2/',
21 'md5': '72cb7eab33e54314e1790da402d3c9c3',
24 'display_id': 'brat-2',
27 'description': 'md5:5751f4fe345a58e1692585c361294bd8',
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]),
75 self._sort_formats(formats)
79 'display_id': display_id,
81 'description': description,
82 'thumbnail': thumbnail,
84 'age_limit': age_limit,