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

[mixcloud] Add support for new frontend #14132

Closed
wants to merge 7 commits into from
Closed

[mixcloud] Add support for new frontend #14132

wants to merge 7 commits into from

Conversation

ishitatsuyuki
Copy link
Contributor

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:

  • I am the original author of this code and I am willing to release it under Unlicense

What is the purpose of your pull request?

  • Bug fix
  • Improvement

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.

@ishitatsuyuki
Copy link
Contributor Author

@dstftw Friendly ping, is there anything that I should elaborate?

{
'format_id': 'dash',
'url': self._decrypt_xor_cipher(key, base64.b64decode(info_json['streamInfo']['dashUrl']))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 151-162 code duplication.
  2. Missing format keys should not breaks extraction.
  3. HLS and DASH should be extracted with appropriate _extract_* methods.
  4. HLS and DASH extraction should be non fatal.

uploader = info_json['owner']['displayName']
uploader_id = info_json['owner']['username']
description = info_json['description']
view_count = info_json['plays']
Copy link
Collaborator

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.

for item in full_info_json:
item_data = item.get("cloudcast", {}) \
.get("data", {}) \
.get("cloudcastLookup", {})
Copy link
Collaborator

Choose a reason for hiding this comment

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

try_get, single quotes.

@kayb94
Copy link
Contributor

kayb94 commented Sep 12, 2017

Not sure if that is intented or not:
I just tried out your branch, ishitatsuyuki, with the media from #14088 and had to specify format as normal to get a listenable audio.


 > python -m youtube_dl https://www.mixcloud.com/aemidesign/mdma/ --list-formats[mixcloud] aemidesign-mdma: Downloading webpage
[mixcloud] aemidesign-mdma: Downloading webpage
[info] Available formats for aemidesign-mdma:
format code  extension  resolution note
normal       m4a        unknown    
hls          m3u8       unknown    
dash         mpd        unknown    (best)
 > python -m youtube_dl https://www.mixcloud.com/aemidesign/mdma/ -f normal
[mixcloud] aemidesign-mdma: Downloading webpage
[mixcloud] aemidesign-mdma: Downloading webpage
[download] Destination: MDMA-aemidesign-mdma.m4a
[download]  14.4% of 32.57MiB at  1.25MiB/s ETA 00:22^C
ERROR: Interrupted by user

The other file is just 4K.

 > du -h MDMA-aemidesign-mdma.mpd 
4.0K	MDMA-aemidesign-mdma.mpd

Feel free to ignore, if I got something wrong here.

@ishitatsuyuki
Copy link
Contributor Author

I'm using DASH with mpv without issues. Their server seems to terminate the connection weirdly though.

@ishitatsuyuki
Copy link
Contributor Author

@kayb94 thanks for pointing out. That was indeed my mistake.

@dstftw I hope I addressed all your comments.

@kayb94
Copy link
Contributor

kayb94 commented Sep 13, 2017

Glad to be able to help!
Regards

There seems to be some "special" URLs that are not served from their CDN.
@ishitatsuyuki
Copy link
Contributor Author

@dstftw friendly ping, I think this is ready for another review!


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))
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

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]:
Copy link
Collaborator

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.

@ishitatsuyuki
Copy link
Contributor Author

@dstftw another review ping. If you have solutions to code duplication, please tell me how to do so.

@dstftw dstftw closed this in 095774e Sep 22, 2017
dstftw added a commit that referenced this pull request Sep 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants