-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[mixcloud] Add support for new frontend #14132
Changes from 1 commit
20dbcfc
d5a11b4
7ab078e
6dd969a
b507277
a26f294
79ec7fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
ExtractorError, | ||
OnDemandPagedList, | ||
str_to_int, | ||
) | ||
try_get) | ||
|
||
|
||
class MixcloudIE(InfoExtractor): | ||
|
@@ -81,12 +81,8 @@ def _real_extract(self, url): | |
full_info_json = self._parse_json(self._html_search_regex( | ||
r'<script id="relay-data" type="text/x-mixcloud">([^<]+)</script>', webpage, 'play info'), 'play info') | ||
for item in full_info_json: | ||
item_data = item.get("cloudcast", {}) \ | ||
.get("data", {}) \ | ||
.get("cloudcastLookup", {}) | ||
if item_data \ | ||
.get("streamInfo", {}) \ | ||
.get("url", "") != "": | ||
item_data = try_get(item, lambda x: x['cloudcast']['data']['cloudcastLookup']) | ||
if try_get(item_data, lambda x: x['streamInfo']['url']) not in ['', None]: | ||
info_json = item_data | ||
break | ||
|
||
|
@@ -108,7 +104,7 @@ def _real_extract(self, url): | |
kpa_target = encrypted_play_info | ||
else: | ||
kp = 'https://' | ||
kpa_target = base64.b64decode(info_json["streamInfo"]["url"]) | ||
kpa_target = base64.b64decode(info_json['streamInfo']['url']) | ||
partial_key = self._decrypt_xor_cipher(kpa_target, kp) | ||
for quote in ["'", '"']: | ||
key = self._search_regex(r'{0}({1}[^{0}]*){0}'.format(quote, re.escape(partial_key)), js, | ||
|
@@ -142,25 +138,26 @@ def _real_extract(self, url): | |
|
||
else: | ||
title = info_json['name'] | ||
thumbnail = 'https://thumbnailer.mixcloud.com/unsafe/600x600/' + info_json['picture']['urlRoot'] | ||
uploader = info_json['owner']['displayName'] | ||
uploader_id = info_json['owner']['username'] | ||
description = info_json['description'] | ||
view_count = info_json['plays'] | ||
formats = [ | ||
{ | ||
'format_id': 'normal', | ||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['url'])) | ||
}, | ||
{ | ||
'format_id': 'hls', | ||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['hlsUrl'])) | ||
}, | ||
{ | ||
'format_id': 'dash', | ||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['dashUrl'])) | ||
} | ||
] | ||
thumbnail = try_get(info_json, | ||
lambda x: 'https://thumbnailer.mixcloud.com/unsafe/600x600/' + x['picture']['urlRoot']) | ||
uploader = try_get(info_json, lambda x: x['owner']['displayName']) | ||
uploader_id = try_get(info_json, lambda x: x['owner']['username']) | ||
description = try_get(info_json, lambda x: x['description']) | ||
view_count = try_get(info_json, lambda x: x['plays']) | ||
formats = [{ | ||
'format_id': 'normal', | ||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['url'])) | ||
}] | ||
|
||
hls_encrypted = try_get(info_json, lambda x: x['streamInfo']['hlsUrl']) | ||
if hls_encrypted is not None: | ||
hls_url = self._decrypt_xor_cipher(key, base64.b64decode(hls_encrypted)) | ||
formats.extend(self._extract_m3u8_formats(hls_url, title)) | ||
|
||
dash_encrypted = try_get(info_json, lambda x: x['streamInfo']['dashUrl']) | ||
if dash_encrypted is not None: | ||
dash_url = self._decrypt_xor_cipher(key, base64.b64decode(dash_encrypted)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 157, 160-162, 165-167 code duplication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would you suggest then? The duplication is minimal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extracting duplicate code into a function obviously. |
||
formats.extend(self._extract_mpd_formats(dash_url, title)) | ||
|
||
return { | ||
'id': track_id, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if try_get(item_data, lambda x: x['streamInfo']['url'])
is enough.