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.

56 lines
1.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. float_or_none,
  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. 'timestamp': 1462283735,
  18. 'upload_date': '20160503',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. webpage = self._download_webpage(url, video_id)
  24. msi_id = self._search_regex(
  25. r"(?s)config\s*=\s*{.+?video_id\s*:\s*'([^']+)'", webpage, 'msi id')
  26. msi_data = self._download_json(
  27. 'http://player.fc-zenit.ru/msi/video', msi_id, query={
  28. 'video': msi_id,
  29. })['data']
  30. title = msi_data['name']
  31. formats = [{
  32. 'format_id': q.get('label'),
  33. 'url': q['url'],
  34. 'height': int_or_none(q.get('label')),
  35. } for q in msi_data['qualities'] if q.get('url')]
  36. self._sort_formats(formats)
  37. tags = [tag['label'] for tag in msi_data.get('tags', []) if tag.get('label')]
  38. return {
  39. 'id': video_id,
  40. 'title': title,
  41. 'thumbnail': msi_data.get('preview'),
  42. 'formats': formats,
  43. 'duration': float_or_none(msi_data.get('duration')),
  44. 'timestamp': int_or_none(msi_data.get('date')),
  45. 'tags': tags,
  46. }