]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fczenit.py
Update Standards-Version to 3.9.8 (no changes required).
[youtubedl] / youtube_dl / extractor / fczenit.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urlparse
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 },
18 }
19
20 def _real_extract(self, url):
21 video_id = self._match_id(url)
22 webpage = self._download_webpage(url, video_id)
23
24 video_title = self._html_search_regex(
25 r'<[^>]+class=\"photoalbum__title\">([^<]+)', webpage, 'title')
26
27 video_items = self._parse_json(self._search_regex(
28 r'arrPath\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage, 'video items'),
29 video_id)
30
31 def merge_dicts(*dicts):
32 ret = {}
33 for a_dict in dicts:
34 ret.update(a_dict)
35 return ret
36
37 formats = [{
38 'url': compat_urlparse.urljoin(url, video_url),
39 'tbr': int(tbr),
40 } for tbr, video_url in merge_dicts(*video_items).items()]
41
42 self._sort_formats(formats)
43
44 return {
45 'id': video_id,
46 'title': video_title,
47 'formats': formats,
48 }