]>
Commit | Line | Data |
---|---|---|
c3deacd5 S |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import random | |
5 | ||
6 | from .common import InfoExtractor | |
15707c7e | 7 | from ..compat import compat_urllib_parse_urlencode |
c3deacd5 S |
8 | from ..utils import ( |
9 | sanitized_Request, | |
10 | xpath_text, | |
11 | ) | |
12 | ||
13 | ||
14 | class MatchTVIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://matchtv\.ru/?#live-player' | |
16 | _TEST = { | |
17 | 'url': 'http://matchtv.ru/#live-player', | |
18 | 'info_dict': { | |
19 | 'id': 'matchtv-live', | |
20 | 'ext': 'flv', | |
21 | 'title': 're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$', | |
22 | 'is_live': True, | |
23 | }, | |
24 | 'params': { | |
25 | 'skip_download': True, | |
26 | }, | |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
30 | video_id = 'matchtv-live' | |
31 | request = sanitized_Request( | |
15707c7e | 32 | 'http://player.matchtv.ntvplus.tv/player/smil?%s' % compat_urllib_parse_urlencode({ |
c3deacd5 S |
33 | 'ts': '', |
34 | 'quality': 'SD', | |
35 | 'contentId': '561d2c0df7159b37178b4567', | |
36 | 'sign': '', | |
37 | 'includeHighlights': '0', | |
38 | 'userId': '', | |
39 | 'sessionId': random.randint(1, 1000000000), | |
40 | 'contentType': 'channel', | |
41 | 'timeShift': '0', | |
42 | 'platform': 'portal', | |
43 | }), | |
44 | headers={ | |
45 | 'Referer': 'http://player.matchtv.ntvplus.tv/embed-player/NTVEmbedPlayer.swf', | |
46 | }) | |
47 | video_url = self._download_json(request, video_id)['data']['videoUrl'] | |
48 | f4m_url = xpath_text(self._download_xml(video_url, video_id), './to') | |
49 | formats = self._extract_f4m_formats(f4m_url, video_id) | |
19dbaeec | 50 | self._sort_formats(formats) |
c3deacd5 S |
51 | return { |
52 | 'id': video_id, | |
53 | 'title': self._live_title('Матч ТВ - Прямой эфир'), | |
54 | 'is_live': True, | |
55 | 'formats': formats, | |
56 | } |