matchtv.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from .common import InfoExtractor
  2. class MatchTVIE(InfoExtractor):
  3. _VALID_URL = [
  4. r'https?://matchtv\.ru/on-air/?(?:$|[?#])',
  5. r'https?://video\.matchtv\.ru/iframe/channel/106/?(?:$|[?#])',
  6. ]
  7. _TESTS = [{
  8. 'url': 'http://matchtv.ru/on-air/',
  9. 'info_dict': {
  10. 'id': 'matchtv-live',
  11. 'ext': 'mp4',
  12. 'title': r're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
  13. 'live_status': 'is_live',
  14. },
  15. 'params': {
  16. 'skip_download': True,
  17. },
  18. }, {
  19. 'url': 'https://video.matchtv.ru/iframe/channel/106',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. video_id = 'matchtv-live'
  24. webpage = self._download_webpage('https://video.matchtv.ru/iframe/channel/106', video_id)
  25. video_url = self._html_search_regex(
  26. r'data-config="config=(https?://[^?"]+)[?"]', webpage, 'video URL').replace('/feed/', '/media/') + '.m3u8'
  27. return {
  28. 'id': video_id,
  29. 'title': 'Матч ТВ - Прямой эфир',
  30. 'is_live': True,
  31. 'formats': self._extract_m3u8_formats(video_url, video_id, 'mp4', live=True),
  32. }