From 16311c00358936ccf8144eb1f1975be0f8485af5 Mon Sep 17 00:00:00 2001 From: Logan B Date: Wed, 16 Jun 2021 02:52:39 +1200 Subject: [PATCH 1/4] Fix umg:de as API site no longer resolves Site now also issues a "master" m3u8 which has the audioonly and video quality options instead of different formats. Updated the script to not rely on the "height" as this m3u8 doesn't have it. --- youtube_dl/extractor/umg.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/umg.py b/youtube_dl/extractor/umg.py index d815cd9a6ba..e357680a321 100644 --- a/youtube_dl/extractor/umg.py +++ b/youtube_dl/extractor/umg.py @@ -28,7 +28,7 @@ class UMGDeIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) video_data = self._download_json( - 'https://api.universal-music.de/graphql', + 'https://graphql.universal-music.de/', video_id, query={ 'query': '''{ universalMusic(channel:16) { @@ -50,18 +50,11 @@ def _real_extract(self, url): }''' % video_id})['data']['universalMusic']['video'] title = video_data['headline'] - hls_url_template = 'http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/' + '/'.join(list(video_id)) + '/content/%s/file/playlist.m3u8' + hls_url_template = 'https://hls.universal-music.de/' + '/'.join(list(video_id)) + '/playlist.m3u8' thumbnails = [] formats = [] - def add_m3u8_format(format_id): - m3u8_formats = self._extract_m3u8_formats( - hls_url_template % format_id, video_id, 'mp4', - 'm3u8_native', m3u8_id='hls', fatal='False') - if m3u8_formats and m3u8_formats[0].get('height'): - formats.extend(m3u8_formats) - for f in video_data.get('formats', []): f_url = f.get('url') mime_type = f.get('mimeType') @@ -77,11 +70,6 @@ def add_m3u8_format(format_id): if f_type == 'Image': thumbnails.append(fmt) elif f_type == 'Video': - format_id = f.get('formatId') - if format_id: - fmt['format_id'] = format_id - if mime_type == 'video/mp4': - add_m3u8_format(format_id) urlh = self._request_webpage(f_url, video_id, fatal=False) if urlh: first_byte = urlh.read(1) @@ -89,8 +77,10 @@ def add_m3u8_format(format_id): continue formats.append(fmt) if not formats: - for format_id in (867, 836, 940): - add_m3u8_format(format_id) + m3u8_formats = self._extract_m3u8_formats( + hls_url_template, 'mp4', + 'm3u8_native', m3u8_id='hls', fatal='False') + formats.extend(m3u8_formats) self._sort_formats(formats, ('width', 'height', 'filesize', 'tbr')) return { From 239c750c67a21401c925da5c9ef9b26cb3f9c6c7 Mon Sep 17 00:00:00 2001 From: Logan B Date: Thu, 17 Jun 2021 19:11:47 +1200 Subject: [PATCH 2/4] Changes as requested --- youtube_dl/extractor/umg.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/umg.py b/youtube_dl/extractor/umg.py index e357680a321..1d0d0a09114 100644 --- a/youtube_dl/extractor/umg.py +++ b/youtube_dl/extractor/umg.py @@ -50,11 +50,18 @@ def _real_extract(self, url): }''' % video_id})['data']['universalMusic']['video'] title = video_data['headline'] - hls_url_template = 'https://hls.universal-music.de/' + '/'.join(list(video_id)) + '/playlist.m3u8' + hls_url_template = 'http://mediadelivery.universal-music-services.de/vod/mp4:autofill/storage/' + '/'.join(list(video_id)) + '/content/%s/file/playlist.m3u8' thumbnails = [] formats = [] + def add_m3u8_format(format_id): + m3u8_formats = self._extract_m3u8_formats( + hls_url_template % format_id, video_id, 'mp4', + 'm3u8_native', m3u8_id='hls', fatal='False') + if m3u8_formats: + formats.extend(m3u8_formats) + for f in video_data.get('formats', []): f_url = f.get('url') mime_type = f.get('mimeType') @@ -70,6 +77,11 @@ def _real_extract(self, url): if f_type == 'Image': thumbnails.append(fmt) elif f_type == 'Video': + format_id = f.get('formatId') + if format_id: + fmt['format_id'] = format_id + if mime_type == 'video/mp4': + add_m3u8_format(format_id) urlh = self._request_webpage(f_url, video_id, fatal=False) if urlh: first_byte = urlh.read(1) @@ -77,10 +89,8 @@ def _real_extract(self, url): continue formats.append(fmt) if not formats: - m3u8_formats = self._extract_m3u8_formats( - hls_url_template, 'mp4', - 'm3u8_native', m3u8_id='hls', fatal='False') - formats.extend(m3u8_formats) + for format_id in (867, 836, 940): + add_m3u8_format(format_id) self._sort_formats(formats, ('width', 'height', 'filesize', 'tbr')) return { From fc1f943da47bb7aa3a4f07f85b758eed3d266f5f Mon Sep 17 00:00:00 2001 From: Sergey M Date: Mon, 21 Jun 2021 00:38:39 +0700 Subject: [PATCH 3/4] Update umg.py --- youtube_dl/extractor/umg.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/umg.py b/youtube_dl/extractor/umg.py index 1d0d0a09114..69836184517 100644 --- a/youtube_dl/extractor/umg.py +++ b/youtube_dl/extractor/umg.py @@ -56,11 +56,9 @@ def _real_extract(self, url): formats = [] def add_m3u8_format(format_id): - m3u8_formats = self._extract_m3u8_formats( + formats.extend(self._extract_m3u8_formats( hls_url_template % format_id, video_id, 'mp4', - 'm3u8_native', m3u8_id='hls', fatal='False') - if m3u8_formats: - formats.extend(m3u8_formats) + 'm3u8_native', m3u8_id='hls', fatal='False')) for f in video_data.get('formats', []): f_url = f.get('url') From 20163bf3147a276a4db7f2d5c4712d2895c5b22d Mon Sep 17 00:00:00 2001 From: Sergey M Date: Mon, 21 Jun 2021 00:39:16 +0700 Subject: [PATCH 4/4] Update umg.py --- youtube_dl/extractor/umg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/umg.py b/youtube_dl/extractor/umg.py index 69836184517..47948b6ce18 100644 --- a/youtube_dl/extractor/umg.py +++ b/youtube_dl/extractor/umg.py @@ -58,7 +58,7 @@ def _real_extract(self, url): def add_m3u8_format(format_id): formats.extend(self._extract_m3u8_formats( hls_url_template % format_id, video_id, 'mp4', - 'm3u8_native', m3u8_id='hls', fatal='False')) + 'm3u8_native', m3u8_id='hls', fatal=False)) for f in video_data.get('formats', []): f_url = f.get('url')