-
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
Conversation
@dstftw Friendly ping, is there anything that I should elaborate? |
youtube_dl/extractor/mixcloud.py
Outdated
{ | ||
'format_id': 'dash', | ||
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['dashUrl'])) | ||
} |
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.
- 151-162 code duplication.
- Missing format keys should not breaks extraction.
- HLS and DASH should be extracted with appropriate
_extract_*
methods. - HLS and DASH extraction should be non fatal.
youtube_dl/extractor/mixcloud.py
Outdated
uploader = info_json['owner']['displayName'] | ||
uploader_id = info_json['owner']['username'] | ||
description = info_json['description'] | ||
view_count = info_json['plays'] |
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.
None of the optional fields should break extraction if missing.
youtube_dl/extractor/mixcloud.py
Outdated
for item in full_info_json: | ||
item_data = item.get("cloudcast", {}) \ | ||
.get("data", {}) \ | ||
.get("cloudcastLookup", {}) |
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.
try_get
, single quotes.
Not sure if that is intented or not:
The other file is just 4K.
Feel free to ignore, if I got something wrong here. |
I'm using DASH with mpv without issues. Their server seems to terminate the connection weirdly though. |
Glad to be able to help! |
There seems to be some "special" URLs that are not served from their CDN.
@dstftw friendly ping, I think this is ready for another review! |
youtube_dl/extractor/mixcloud.py
Outdated
|
||
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Extracting duplicate code into a function obviously.
youtube_dl/extractor/mixcloud.py
Outdated
r'<script id="relay-data" type="text/x-mixcloud">([^<]+)</script>', webpage, 'play info'), 'play info') | ||
for item in full_info_json: | ||
item_data = try_get(item, lambda x: x['cloudcast']['data']['cloudcastLookup']) | ||
if try_get(item_data, lambda x: x['streamInfo']['url']) not in ['', None]: |
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.
@dstftw another review ping. If you have solutions to code duplication, please tell me how to do so. |
Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
The decryption part is refactored to use iterators, and therefore a compat function was added.
The code is mostly self explanatory.