Open radusuciu opened 4 years ago
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.
Note however, that this may not be functional right now: https://github.com/ytdl-org/youtube-dl/issues/24394
Eg. https://github.com/ytdl-org/youtube-dl/commit/3bed621750b7fe25afc04a0131664bbbc610c563#comments