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