Address review issues
This commit is contained in:
parent
d5a11b4948
commit
7ab078eae9
@ -18,7 +18,7 @@ from ..utils import (
|
|||||||
ExtractorError,
|
ExtractorError,
|
||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
)
|
try_get)
|
||||||
|
|
||||||
|
|
||||||
class MixcloudIE(InfoExtractor):
|
class MixcloudIE(InfoExtractor):
|
||||||
@ -81,12 +81,8 @@ class MixcloudIE(InfoExtractor):
|
|||||||
full_info_json = self._parse_json(self._html_search_regex(
|
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')
|
r'<script id="relay-data" type="text/x-mixcloud">([^<]+)</script>', webpage, 'play info'), 'play info')
|
||||||
for item in full_info_json:
|
for item in full_info_json:
|
||||||
item_data = item.get("cloudcast", {}) \
|
item_data = try_get(item, lambda x: x['cloudcast']['data']['cloudcastLookup'])
|
||||||
.get("data", {}) \
|
if try_get(item_data, lambda x: x['streamInfo']['url']) not in ['', None]:
|
||||||
.get("cloudcastLookup", {})
|
|
||||||
if item_data \
|
|
||||||
.get("streamInfo", {}) \
|
|
||||||
.get("url", "") != "":
|
|
||||||
info_json = item_data
|
info_json = item_data
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -108,7 +104,7 @@ class MixcloudIE(InfoExtractor):
|
|||||||
kpa_target = encrypted_play_info
|
kpa_target = encrypted_play_info
|
||||||
else:
|
else:
|
||||||
kp = 'https://'
|
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)
|
partial_key = self._decrypt_xor_cipher(kpa_target, kp)
|
||||||
for quote in ["'", '"']:
|
for quote in ["'", '"']:
|
||||||
key = self._search_regex(r'{0}({1}[^{0}]*){0}'.format(quote, re.escape(partial_key)), js,
|
key = self._search_regex(r'{0}({1}[^{0}]*){0}'.format(quote, re.escape(partial_key)), js,
|
||||||
@ -142,25 +138,26 @@ class MixcloudIE(InfoExtractor):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
title = info_json['name']
|
title = info_json['name']
|
||||||
thumbnail = 'https://thumbnailer.mixcloud.com/unsafe/600x600/' + info_json['picture']['urlRoot']
|
thumbnail = try_get(info_json,
|
||||||
uploader = info_json['owner']['displayName']
|
lambda x: 'https://thumbnailer.mixcloud.com/unsafe/600x600/' + x['picture']['urlRoot'])
|
||||||
uploader_id = info_json['owner']['username']
|
uploader = try_get(info_json, lambda x: x['owner']['displayName'])
|
||||||
description = info_json['description']
|
uploader_id = try_get(info_json, lambda x: x['owner']['username'])
|
||||||
view_count = info_json['plays']
|
description = try_get(info_json, lambda x: x['description'])
|
||||||
formats = [
|
view_count = try_get(info_json, lambda x: x['plays'])
|
||||||
{
|
formats = [{
|
||||||
'format_id': 'normal',
|
'format_id': 'normal',
|
||||||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['url']))
|
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['url']))
|
||||||
},
|
}]
|
||||||
{
|
|
||||||
'format_id': 'hls',
|
hls_encrypted = try_get(info_json, lambda x: x['streamInfo']['hlsUrl'])
|
||||||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['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))
|
||||||
'format_id': 'dash',
|
|
||||||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['dashUrl']))
|
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))
|
||||||
|
formats.extend(self._extract_mpd_formats(dash_url, title))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': track_id,
|
'id': track_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user