]>
Commit | Line | Data |
---|---|---|
14ae11ef S |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | ||
6 | ||
7 | class VyboryMosIE(InfoExtractor): | |
8 | _VALID_URL = r'https?://vybory\.mos\.ru/(?:#precinct/|account/channels\?.*?\bstation_id=)(?P<id>\d+)' | |
9 | _TESTS = [{ | |
10 | 'url': 'http://vybory.mos.ru/#precinct/13636', | |
11 | 'info_dict': { | |
12 | 'id': '13636', | |
13 | 'ext': 'mp4', | |
14 | 'title': 're:^Участковая избирательная комиссия №2231 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', | |
15 | 'description': 'Россия, Москва, улица Введенского, 32А', | |
16 | 'is_live': True, | |
17 | }, | |
18 | 'params': { | |
19 | 'skip_download': True, | |
20 | } | |
21 | }, { | |
22 | 'url': 'http://vybory.mos.ru/account/channels?station_id=13636', | |
23 | 'only_matching': True, | |
24 | }] | |
25 | ||
26 | def _real_extract(self, url): | |
27 | station_id = self._match_id(url) | |
28 | ||
29 | channels = self._download_json( | |
30 | 'http://vybory.mos.ru/account/channels?station_id=%s' % station_id, | |
31 | station_id) | |
32 | ||
33 | formats = [] | |
34 | for cam_num, (sid, hosts, name, _) in enumerate(channels, 1): | |
35 | for num, host in enumerate(hosts, 1): | |
36 | formats.append({ | |
37 | 'url': 'http://%s/master.m3u8?sid=%s' % (host, sid), | |
38 | 'ext': 'mp4', | |
39 | 'format_id': 'camera%d-host%d' % (cam_num, num), | |
40 | 'format_note': '%s, %s' % (name, host), | |
41 | }) | |
42 | ||
43 | info = self._download_json( | |
44 | 'http://vybory.mos.ru/json/voting_stations/136/%s.json' % station_id, | |
45 | station_id, 'Downloading station info') | |
46 | ||
47 | title = info['name'] | |
48 | ||
49 | return { | |
50 | 'id': station_id, | |
51 | 'title': self._live_title(title), | |
52 | 'description': info.get('address'), | |
53 | 'is_live': True, | |
54 | 'formats': formats, | |
55 | } |