[fczenit] fix extraction

This commit is contained in:
Remita Amine 2017-11-25 19:28:26 +01:00
parent 87dac57cf6
commit 93f3f10cdc
1 changed files with 24 additions and 16 deletions

View File

@ -2,7 +2,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import compat_urlparse from ..utils import (
int_or_none,
float_or_none,
)
class FczenitIE(InfoExtractor): class FczenitIE(InfoExtractor):
@ -14,6 +17,8 @@ class FczenitIE(InfoExtractor):
'id': '41044', 'id': '41044',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»', 'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»',
'timestamp': 1462283735,
'upload_date': '20160503',
}, },
} }
@ -21,28 +26,31 @@ class FczenitIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_title = self._html_search_regex( msi_id = self._search_regex(
r'<[^>]+class=\"photoalbum__title\">([^<]+)', webpage, 'title') r"(?s)config\s*=\s*{.+?video_id\s*:\s*'([^']+)'", webpage, 'msi id')
video_items = self._parse_json(self._search_regex( msi_data = self._download_json(
r'arrPath\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage, 'video items'), 'http://player.fc-zenit.ru/msi/video', msi_id, query={
video_id) 'video': msi_id,
})['data']
def merge_dicts(*dicts): title = msi_data['name']
ret = {}
for a_dict in dicts:
ret.update(a_dict)
return ret
formats = [{ formats = [{
'url': compat_urlparse.urljoin(url, video_url), 'format_id': q.get('label'),
'tbr': int(tbr), 'url': q['url'],
} for tbr, video_url in merge_dicts(*video_items).items()] 'height': int_or_none(q.get('label')),
} for q in msi_data['qualities'] if q.get('url')]
self._sort_formats(formats) self._sort_formats(formats)
tags = [tag['label'] for tag in msi_data.get('tags', []) if tag.get('label')]
return { return {
'id': video_id, 'id': video_id,
'title': video_title, 'title': title,
'thumbnail': msi_data.get('preview'),
'formats': formats, 'formats': formats,
'duration': float_or_none(msi_data.get('duration')),
'timestamp': int_or_none(msi_data.get('date')),
'tags': tags,
} }