Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix umg:de as API site no longer resolves #29304

Merged
merged 5 commits into from
Jun 20, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions youtube_dl/extractor/umg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')
Expand All @@ -77,20 +70,17 @@ 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)
if first_byte not in (b'F', b'\x00'):
continue
formats.append(fmt)
if not formats:
for format_id in (867, 836, 940):
add_m3u8_format(format_id)
Copy link
Collaborator

@dstftw dstftw Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's all correct code [53-93], do not remove it. Fix add_m3u8_format instead.

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 {
Expand Down