]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/performgroup.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / performgroup.py
1 from .common import InfoExtractor
2 from ..utils import int_or_none
3
4
5 class PerformGroupIE(InfoExtractor):
6 _VALID_URL = r'https?://player\.performgroup\.com/eplayer(?:/eplayer\.html|\.js)#/?(?P<id>[0-9a-f]{26})\.(?P<auth_token>[0-9a-z]{26})'
7 _TESTS = [{
8 # http://www.faz.net/aktuell/sport/fussball/wm-2018-playoffs-schweiz-besiegt-nordirland-1-0-15286104.html
9 'url': 'http://player.performgroup.com/eplayer/eplayer.html#d478c41c5d192f56b9aa859de8.1w4crrej5w14e1ed4s1ce4ykab',
10 'md5': '259cb03d142e2e52471e8837ecacb29f',
11 'info_dict': {
12 'id': 'xgrwobuzumes1lwjxtcdpwgxd',
13 'ext': 'mp4',
14 'title': 'Liga MX: Keine Einsicht nach Horrorfoul',
15 'description': 'md5:7cd3b459c82725b021e046ab10bf1c5b',
16 'timestamp': 1511533477,
17 'upload_date': '20171124',
18 }
19 }]
20
21 def _call_api(self, service, auth_token, content_id, referer_url):
22 return self._download_json(
23 'http://ep3.performfeeds.com/ep%s/%s/%s/' % (service, auth_token, content_id),
24 content_id, headers={
25 'Referer': referer_url,
26 'Origin': 'http://player.performgroup.com',
27 }, query={
28 '_fmt': 'json',
29 })
30
31 def _real_extract(self, url):
32 player_id, auth_token = self._match_valid_url(url).groups()
33 bootstrap = self._call_api('bootstrap', auth_token, player_id, url)
34 video = bootstrap['config']['dataSource']['sourceItems'][0]['videos'][0]
35 video_id = video['uuid']
36 vod = self._call_api('vod', auth_token, video_id, url)
37 media = vod['videos']['video'][0]['media']
38
39 formats = []
40 hls_url = media.get('hls', {}).get('url')
41 if hls_url:
42 formats.extend(self._extract_m3u8_formats(hls_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
43
44 hds_url = media.get('hds', {}).get('url')
45 if hds_url:
46 formats.extend(self._extract_f4m_formats(hds_url + '?hdcore', video_id, f4m_id='hds', fatal=False))
47
48 for c in media.get('content', []):
49 c_url = c.get('url')
50 if not c_url:
51 continue
52 tbr = int_or_none(c.get('bitrate'), 1000)
53 format_id = 'http'
54 if tbr:
55 format_id += '-%d' % tbr
56 formats.append({
57 'format_id': format_id,
58 'url': c_url,
59 'tbr': tbr,
60 'width': int_or_none(c.get('width')),
61 'height': int_or_none(c.get('height')),
62 'filesize': int_or_none(c.get('fileSize')),
63 'vcodec': c.get('type'),
64 'fps': int_or_none(c.get('videoFrameRate')),
65 'vbr': int_or_none(c.get('videoRate'), 1000),
66 'abr': int_or_none(c.get('audioRate'), 1000),
67 })
68
69 return {
70 'id': video_id,
71 'title': video['title'],
72 'description': video.get('description'),
73 'thumbnail': video.get('poster'),
74 'duration': int_or_none(video.get('duration')),
75 'timestamp': int_or_none(video.get('publishedTime'), 1000),
76 'formats': formats,
77 }