]>
Commit | Line | Data |
---|---|---|
3dc582e5 | 1 | from .common import InfoExtractor |
93f3f10c RA |
2 | from ..utils import ( |
3 | int_or_none, | |
4 | float_or_none, | |
5 | ) | |
3dc582e5 | 6 | |
7 | ||
8 | class FczenitIE(InfoExtractor): | |
4f8c56eb | 9 | _VALID_URL = r'https?://(?:www\.)?fc-zenit\.ru/video/(?P<id>[0-9]+)' |
3dc582e5 | 10 | _TEST = { |
4f8c56eb YCH |
11 | 'url': 'http://fc-zenit.ru/video/41044/', |
12 | 'md5': '0e3fab421b455e970fa1aa3891e57df0', | |
3dc582e5 | 13 | 'info_dict': { |
4f8c56eb | 14 | 'id': '41044', |
3dc582e5 | 15 | 'ext': 'mp4', |
4f8c56eb | 16 | 'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»', |
93f3f10c RA |
17 | 'timestamp': 1462283735, |
18 | 'upload_date': '20160503', | |
3dc582e5 | 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 | ||
93f3f10c RA |
26 | msi_id = self._search_regex( |
27 | r"(?s)config\s*=\s*{.+?video_id\s*:\s*'([^']+)'", webpage, 'msi id') | |
4f8c56eb | 28 | |
93f3f10c RA |
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'] | |
3dc582e5 | 34 | |
35 | formats = [{ | |
93f3f10c RA |
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')] | |
3dc582e5 | 40 | |
41 | self._sort_formats(formats) | |
42 | ||
93f3f10c RA |
43 | tags = [tag['label'] for tag in msi_data.get('tags', []) if tag.get('label')] |
44 | ||
3dc582e5 | 45 | return { |
46 | 'id': video_id, | |
93f3f10c RA |
47 | 'title': title, |
48 | 'thumbnail': msi_data.get('preview'), | |
3dc582e5 | 49 | 'formats': formats, |
93f3f10c RA |
50 | 'duration': float_or_none(msi_data.get('duration')), |
51 | 'timestamp': int_or_none(msi_data.get('date')), | |
52 | 'tags': tags, | |
3dc582e5 | 53 | } |