logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

matchtv.py (1811B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import random
  4. from .common import InfoExtractor
  5. from ..utils import xpath_text
  6. class MatchTVIE(InfoExtractor):
  7. _VALID_URL = r'https?://matchtv\.ru(?:/on-air|/?#live-player)'
  8. _TESTS = [{
  9. 'url': 'http://matchtv.ru/#live-player',
  10. 'info_dict': {
  11. 'id': 'matchtv-live',
  12. 'ext': 'flv',
  13. 'title': r're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
  14. 'is_live': True,
  15. },
  16. 'params': {
  17. 'skip_download': True,
  18. },
  19. }, {
  20. 'url': 'http://matchtv.ru/on-air/',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = 'matchtv-live'
  25. video_url = self._download_json(
  26. 'http://player.matchtv.ntvplus.tv/player/smil', video_id,
  27. query={
  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. })['data']['videoUrl']
  42. f4m_url = xpath_text(self._download_xml(video_url, video_id), './to')
  43. formats = self._extract_f4m_formats(f4m_url, video_id)
  44. self._sort_formats(formats)
  45. return {
  46. 'id': video_id,
  47. 'title': self._live_title('Матч ТВ - Прямой эфир'),
  48. 'is_live': True,
  49. 'formats': formats,
  50. }