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.

55 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import random
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse_urlencode
  6. from ..utils import (
  7. sanitized_Request,
  8. xpath_text,
  9. )
  10. class MatchTVIE(InfoExtractor):
  11. _VALID_URL = r'https?://matchtv\.ru/?#live-player'
  12. _TEST = {
  13. 'url': 'http://matchtv.ru/#live-player',
  14. 'info_dict': {
  15. 'id': 'matchtv-live',
  16. 'ext': 'flv',
  17. 'title': 're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
  18. 'is_live': True,
  19. },
  20. 'params': {
  21. 'skip_download': True,
  22. },
  23. }
  24. def _real_extract(self, url):
  25. video_id = 'matchtv-live'
  26. request = sanitized_Request(
  27. 'http://player.matchtv.ntvplus.tv/player/smil?%s' % compat_urllib_parse_urlencode({
  28. 'ts': '',
  29. 'quality': 'SD',
  30. 'contentId': '561d2c0df7159b37178b4567',
  31. 'sign': '',
  32. 'includeHighlights': '0',
  33. 'userId': '',
  34. 'sessionId': random.randint(1, 1000000000),
  35. 'contentType': 'channel',
  36. 'timeShift': '0',
  37. 'platform': 'portal',
  38. }),
  39. headers={
  40. 'Referer': 'http://player.matchtv.ntvplus.tv/embed-player/NTVEmbedPlayer.swf',
  41. })
  42. video_url = self._download_json(request, video_id)['data']['videoUrl']
  43. f4m_url = xpath_text(self._download_xml(video_url, video_id), './to')
  44. formats = self._extract_f4m_formats(f4m_url, video_id)
  45. return {
  46. 'id': video_id,
  47. 'title': self._live_title('Матч ТВ - Прямой эфир'),
  48. 'is_live': True,
  49. 'formats': formats,
  50. }