1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-18 08:53:10 +01:00
yt-dlp/youtube_dl/extractor/fczenit.py

49 lines
1.4 KiB
Python
Raw Normal View History

2015-10-12 07:25:57 +02:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import compat_urlparse
2015-10-12 07:25:57 +02:00
class FczenitIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?fc-zenit\.ru/video/(?P<id>[0-9]+)'
2015-10-12 07:25:57 +02:00
_TEST = {
'url': 'http://fc-zenit.ru/video/41044/',
'md5': '0e3fab421b455e970fa1aa3891e57df0',
2015-10-12 07:25:57 +02:00
'info_dict': {
'id': '41044',
2015-10-12 07:25:57 +02:00
'ext': 'mp4',
'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»',
2015-10-12 07:25:57 +02:00
},
}
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
video_title = self._html_search_regex(
r'<[^>]+class=\"photoalbum__title\">([^<]+)', webpage, 'title')
video_items = self._parse_json(self._search_regex(
r'arrPath\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage, 'video items'),
video_id)
2015-10-12 07:25:57 +02:00
def merge_dicts(*dicts):
ret = {}
for a_dict in dicts:
ret.update(a_dict)
return ret
2015-10-12 07:25:57 +02:00
formats = [{
'url': compat_urlparse.urljoin(url, video_url),
'tbr': int(tbr),
} for tbr, video_url in merge_dicts(*video_items).items()]
2015-10-12 07:25:57 +02:00
self._sort_formats(formats)
return {
'id': video_id,
'title': video_title,
'formats': formats,
}