Last active
April 12, 2024 17:50
-
-
Save heyjoeway/496d96cec0d569f86cdc59aa92a22cad to your computer and use it in GitHub Desktop.
Get public SoundCloud client ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fuck you soundcloud! :) | |
import urllib.request | |
from pyquery import PyQuery as pq | |
def getUrl(url): | |
with urllib.request.urlopen(url) as f: | |
return f.read().decode('utf-8') | |
def getSoundCloudClientID(): | |
pqHome = pq(url="https://soundcloud.com/") | |
pqScripts = pqHome("html > body > script") | |
for i in range(len(pqScripts)): | |
pqScriptSrc = pqScripts.eq(i).attr("src") | |
if pqScriptSrc is None: | |
continue | |
scriptContent = None | |
try: | |
scriptContent = getUrl(pqScriptSrc) | |
except: | |
continue | |
clientIdStr = 'client_id:"' | |
if not (clientIdStr in scriptContent): | |
continue | |
clientId = scriptContent.split(clientIdStr)[1].split('"')[0] | |
if len(clientId) == 32: | |
return clientId | |
def getSoundCloudUserID(username): | |
pqHome = pq(url=f"https://soundcloud.com/{username}") | |
pqIosUrl = pqHome("html > head > meta[property='al:ios:url']") | |
return pqIosUrl.attr("content").split(":")[2] | |
def getSoundCloudFollowingAll(userId, clientId): | |
following = [] | |
url = f"https://api-v2.soundcloud.com/users/{userId}/followings?client_id={clientId}&limit=200" | |
while not (url is None): | |
data = json.loads(getUrl(url)) | |
following += data["collection"] | |
url = data["next_href"] | |
return following |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This still works btw.