You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. class FczenitIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?fc-zenit\.ru/video/(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://fc-zenit.ru/video/41044/',
  9. 'md5': '0e3fab421b455e970fa1aa3891e57df0',
  10. 'info_dict': {
  11. 'id': '41044',
  12. 'ext': 'mp4',
  13. 'title': 'Так пишется история: казанский разгром ЦСКА на «Зенит-ТВ»',
  14. },
  15. }
  16. def _real_extract(self, url):
  17. video_id = self._match_id(url)
  18. webpage = self._download_webpage(url, video_id)
  19. video_title = self._html_search_regex(
  20. r'<[^>]+class=\"photoalbum__title\">([^<]+)', webpage, 'title')
  21. video_items = self._parse_json(self._search_regex(
  22. r'arrPath\s*=\s*JSON\.parse\(\'(.+)\'\)', webpage, 'video items'),
  23. video_id)
  24. def merge_dicts(*dicts):
  25. ret = {}
  26. for a_dict in dicts:
  27. ret.update(a_dict)
  28. return ret
  29. formats = [{
  30. 'url': compat_urlparse.urljoin(url, video_url),
  31. 'tbr': int(tbr),
  32. } for tbr, video_url in merge_dicts(*video_items).items()]
  33. self._sort_formats(formats)
  34. return {
  35. 'id': video_id,
  36. 'title': video_title,
  37. 'formats': formats,
  38. }