]>
Commit | Line | Data |
---|---|---|
fb8b8fdd S |
1 | # encoding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
fb8b8fdd S |
4 | from .common import InfoExtractor |
5 | from ..utils import ( | |
884ae747 | 6 | float_or_none, |
819039ee | 7 | parse_age_limit, |
fb8b8fdd S |
8 | ) |
9 | ||
10 | ||
11 | class TvigleIE(InfoExtractor): | |
12 | IE_NAME = 'tvigle' | |
13 | IE_DESC = 'Интернет-телевидение Tvigle.ru' | |
819039ee | 14 | _VALID_URL = r'http://(?:www\.)?tvigle\.ru/(?:[^/]+/)+(?P<id>[^/]+)/$' |
c7095dad S |
15 | |
16 | _TESTS = [ | |
17 | { | |
819039ee S |
18 | 'url': 'http://www.tvigle.ru/video/sokrat/', |
19 | 'md5': '36514aed3657d4f70b4b2cef8eb520cd', | |
c7095dad | 20 | 'info_dict': { |
819039ee S |
21 | 'id': '1848932', |
22 | 'display_id': 'sokrat', | |
23 | 'ext': 'flv', | |
24 | 'title': 'Сократ', | |
25 | 'description': 'md5:a05bd01be310074d5833efc6743be95e', | |
26 | 'duration': 6586, | |
27 | 'age_limit': 0, | |
c7095dad S |
28 | }, |
29 | }, | |
30 | { | |
884ae747 S |
31 | 'url': 'http://www.tvigle.ru/video/vladimir-vysotskii/vedushchii-teleprogrammy-60-minut-ssha-o-vladimire-vysotskom/', |
32 | 'md5': 'd9012d7c7c598fe7a11d7fb46dc1f574', | |
c7095dad | 33 | 'info_dict': { |
884ae747 S |
34 | 'id': '5142516', |
35 | 'ext': 'mp4', | |
c7095dad S |
36 | 'title': 'Ведущий телепрограммы «60 минут» (США) о Владимире Высоцком', |
37 | 'description': 'md5:027f7dc872948f14c96d19b4178428a4', | |
884ae747 S |
38 | 'duration': 186.080, |
39 | 'age_limit': 0, | |
c7095dad S |
40 | }, |
41 | }, | |
42 | ] | |
fb8b8fdd S |
43 | |
44 | def _real_extract(self, url): | |
819039ee | 45 | display_id = self._match_id(url) |
fb8b8fdd | 46 | |
884ae747 | 47 | webpage = self._download_webpage(url, display_id) |
fb8b8fdd | 48 | |
884ae747 S |
49 | video_id = self._html_search_regex( |
50 | r'<li class="video-preview current_playing" id="(\d+)">', webpage, 'video id') | |
fb8b8fdd | 51 | |
884ae747 S |
52 | video_data = self._download_json( |
53 | 'http://cloud.tvigle.ru/api/play/video/%s/' % video_id, display_id) | |
fb8b8fdd | 54 | |
884ae747 S |
55 | item = video_data['playlist']['items'][0] |
56 | ||
57 | title = item['title'] | |
58 | description = item['description'] | |
59 | thumbnail = item['thumbnail'] | |
819039ee S |
60 | duration = float_or_none(item.get('durationMilliseconds'), 1000) |
61 | age_limit = parse_age_limit(item.get('ageRestrictions')) | |
fb8b8fdd | 62 | |
884ae747 S |
63 | formats = [] |
64 | for vcodec, fmts in item['videos'].items(): | |
65 | for quality, video_url in fmts.items(): | |
66 | formats.append({ | |
67 | 'url': video_url, | |
68 | 'format_id': '%s-%s' % (vcodec, quality), | |
69 | 'vcodec': vcodec, | |
70 | 'height': int(quality[:-1]), | |
e497a7f2 | 71 | 'filesize': item['video_files_size'][vcodec][quality], |
884ae747 | 72 | }) |
fb8b8fdd S |
73 | self._sort_formats(formats) |
74 | ||
75 | return { | |
76 | 'id': video_id, | |
884ae747 | 77 | 'display_id': display_id, |
fb8b8fdd S |
78 | 'title': title, |
79 | 'description': description, | |
80 | 'thumbnail': thumbnail, | |
884ae747 S |
81 | 'duration': duration, |
82 | 'age_limit': age_limit, | |
fb8b8fdd | 83 | 'formats': formats, |
5f6a1245 | 84 | } |