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

Automatically get client id from soundcloud #11

Open
radusuciu opened this issue Feb 6, 2020 · 2 comments
Open

Automatically get client id from soundcloud #11

radusuciu opened this issue Feb 6, 2020 · 2 comments

Comments

@radusuciu
Copy link
Owner

Eg. ytdl-org/youtube-dl@3bed621#comments

@radusuciu
Copy link
Owner Author

Example code based on youtube-dl implementation:

import requests
import re

def get_client_id():
    raw = requests.get('https://soundcloud.com').text
    scripts = re.findall(r'<script[^>]+src="([^"]+)"', raw)

    for src in reversed(scripts):
        script = requests.get(src).text
        if script:
            match = re.search(r'client_id\s*:\s*"([0-9a-zA-Z]{32})"', script)
            if match:
                client_id = match.group(1)
                return client_id

Should probably wrap with exception.

@radusuciu
Copy link
Owner Author

Note however, that this may not be functional right now: ytdl-org/youtube-dl#24394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant