]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/umg.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / umg.py
CommitLineData
45d20488
RA
1from .common import InfoExtractor
2from ..utils import (
3 int_or_none,
4 parse_filesize,
5 parse_iso8601,
6)
7
8
9class UMGDeIE(InfoExtractor):
df773c3d 10 _WORKING = False
45d20488
RA
11 IE_NAME = 'umg:de'
12 IE_DESC = 'Universal Music Deutschland'
13 _VALID_URL = r'https?://(?:www\.)?universal-music\.de/[^/]+/videos/[^/?#]+-(?P<id>\d+)'
14 _TEST = {
15 'url': 'https://www.universal-music.de/sido/videos/jedes-wort-ist-gold-wert-457803',
16 'md5': 'ebd90f48c80dcc82f77251eb1902634f',
17 'info_dict': {
18 'id': '457803',
19 'ext': 'mp4',
20 'title': 'Jedes Wort ist Gold wert',
21 'timestamp': 1513591800,
22 'upload_date': '20171218',
add96eb9 23 },
45d20488
RA
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 video_data = self._download_json(
ed807c18 29 'https://graphql.universal-music.de/',
45d20488
RA
30 video_id, query={
31 'query': '''{
32 universalMusic(channel:16) {
33 video(id:%s) {
34 headline
35 formats {
36 formatId
37 url
38 type
39 width
40 height
41 mimeType
42 fileSize
43 }
44 duration
45 createdDate
46 }
47 }
add96eb9 48}''' % video_id})['data']['universalMusic']['video'] # noqa: UP031
45d20488
RA
49
50 title = video_data['headline']
51 hls_url_template = 'http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/' + '/'.join(list(video_id)) + '/content/%s/file/playlist.m3u8'
52
53 thumbnails = []
54 formats = []
55
56 def add_m3u8_format(format_id):
ed807c18 57 formats.extend(self._extract_m3u8_formats(
45d20488 58 hls_url_template % format_id, video_id, 'mp4',
ed807c18 59 'm3u8_native', m3u8_id='hls', fatal=False))
45d20488
RA
60
61 for f in video_data.get('formats', []):
62 f_url = f.get('url')
63 mime_type = f.get('mimeType')
64 if not f_url or mime_type == 'application/mxf':
65 continue
66 fmt = {
67 'url': f_url,
68 'width': int_or_none(f.get('width')),
69 'height': int_or_none(f.get('height')),
70 'filesize': parse_filesize(f.get('fileSize')),
71 }
72 f_type = f.get('type')
73 if f_type == 'Image':
74 thumbnails.append(fmt)
75 elif f_type == 'Video':
76 format_id = f.get('formatId')
77 if format_id:
78 fmt['format_id'] = format_id
79 if mime_type == 'video/mp4':
80 add_m3u8_format(format_id)
81 urlh = self._request_webpage(f_url, video_id, fatal=False)
82 if urlh:
83 first_byte = urlh.read(1)
84 if first_byte not in (b'F', b'\x00'):
85 continue
86 formats.append(fmt)
87 if not formats:
88 for format_id in (867, 836, 940):
89 add_m3u8_format(format_id)
45d20488
RA
90
91 return {
92 'id': video_id,
93 'title': title,
94 'duration': int_or_none(video_data.get('duration')),
95 'timestamp': parse_iso8601(video_data.get('createdDate'), ' '),
96 'thumbnails': thumbnails,
97 'formats': formats,
98 }