]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | float_or_none, | |
5 | ) | |
6 | ||
7 | ||
8 | class FczenitIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?fc-zenit\.ru/video/(?P<id>[0-9]+)' | |
10 | _TEST = { | |
11 | 'url': 'http://fc-zenit.ru/video/41044/', | |
12 | 'md5': '0e3fab421b455e970fa1aa3891e57df0', | |
13 | 'info_dict': { | |
14 | 'id': '41044', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»', | |
17 | 'timestamp': 1462283735, | |
18 | 'upload_date': '20160503', | |
19 | }, | |
20 | } | |
21 | ||
22 | def _real_extract(self, url): | |
23 | video_id = self._match_id(url) | |
24 | webpage = self._download_webpage(url, video_id) | |
25 | ||
26 | msi_id = self._search_regex( | |
27 | r"(?s)config\s*=\s*{.+?video_id\s*:\s*'([^']+)'", webpage, 'msi id') | |
28 | ||
29 | msi_data = self._download_json( | |
30 | 'http://player.fc-zenit.ru/msi/video', msi_id, query={ | |
31 | 'video': msi_id, | |
32 | })['data'] | |
33 | title = msi_data['name'] | |
34 | ||
35 | formats = [{ | |
36 | 'format_id': q.get('label'), | |
37 | 'url': q['url'], | |
38 | 'height': int_or_none(q.get('label')), | |
39 | } for q in msi_data['qualities'] if q.get('url')] | |
40 | ||
41 | tags = [tag['label'] for tag in msi_data.get('tags', []) if tag.get('label')] | |
42 | ||
43 | return { | |
44 | 'id': video_id, | |
45 | 'title': title, | |
46 | 'thumbnail': msi_data.get('preview'), | |
47 | 'formats': formats, | |
48 | 'duration': float_or_none(msi_data.get('duration')), | |
49 | 'timestamp': int_or_none(msi_data.get('date')), | |
50 | 'tags': tags, | |
51 | } |