Skip to content

Instantly share code, notes, and snippets.

@sionex-code
Created October 10, 2014 18:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sionex-code/e7fa066020d12c07d4e6 to your computer and use it in GitHub Desktop.
Save sionex-code/e7fa066020d12c07d4e6 to your computer and use it in GitHub Desktop.
/*
this simple snippets will give you downloadable url of soundcloud.
just slap soundcloud url like this way in csharp Download('Soundcloud url'); this will returned downloadable url
*/
public string Download(string songurl){
string returned = null;
HttpWebRequest hc = (HttpWebRequest)WebRequest.Create(songurl);
hc.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36";
HttpWebResponse hresponse = (HttpWebResponse)hc.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(hresponse.GetResponseStream());
string htmldata = sr.ReadToEnd();
Regex r = new Regex("\"id\":(.*?),\"created_at\"");
Match m = r.Match(htmldata);
if (m.Success){
returned = "https://api.soundcloud.com/tracks/" + m.Groups[1].Value + "/download?client_id=b45b1aa10f1ac2941910a7f0d10f8e28";
}
return returned;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment