]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/matchtv.py
[youtube:comments] Add more options for limiting number of comments extracted (#1626)
[yt-dlp.git] / yt_dlp / extractor / matchtv.py
CommitLineData
c3deacd5
S
1# coding: utf-8
2from __future__ import unicode_literals
3
4import random
5
6from .common import InfoExtractor
80ae228b 7from ..utils import xpath_text
c3deacd5
S
8
9
10class MatchTVIE(InfoExtractor):
80ae228b
S
11 _VALID_URL = r'https?://matchtv\.ru(?:/on-air|/?#live-player)'
12 _TESTS = [{
c3deacd5
S
13 'url': 'http://matchtv.ru/#live-player',
14 'info_dict': {
15 'id': 'matchtv-live',
16 'ext': 'flv',
ec85ded8 17 'title': r're:^Матч ТВ - Прямой эфир \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
c3deacd5
S
18 'is_live': True,
19 },
20 'params': {
21 'skip_download': True,
22 },
80ae228b
S
23 }, {
24 'url': 'http://matchtv.ru/on-air/',
25 'only_matching': True,
26 }]
c3deacd5
S
27
28 def _real_extract(self, url):
29 video_id = 'matchtv-live'
80ae228b
S
30 video_url = self._download_json(
31 'http://player.matchtv.ntvplus.tv/player/smil', video_id,
32 query={
c3deacd5
S
33 'ts': '',
34 'quality': 'SD',
35 'contentId': '561d2c0df7159b37178b4567',
36 'sign': '',
37 'includeHighlights': '0',
38 'userId': '',
39 'sessionId': random.randint(1, 1000000000),
40 'contentType': 'channel',
41 'timeShift': '0',
42 'platform': 'portal',
80ae228b 43 },
c3deacd5
S
44 headers={
45 'Referer': 'http://player.matchtv.ntvplus.tv/embed-player/NTVEmbedPlayer.swf',
80ae228b 46 })['data']['videoUrl']
c3deacd5
S
47 f4m_url = xpath_text(self._download_xml(video_url, video_id), './to')
48 formats = self._extract_f4m_formats(f4m_url, video_id)
19dbaeec 49 self._sort_formats(formats)
c3deacd5
S
50 return {
51 'id': video_id,
52 'title': self._live_title('Матч ТВ - Прямой эфир'),
53 'is_live': True,
54 'formats': formats,
55 }