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