Created
October 10, 2014 18:10
-
-
Save sionex-code/e7fa066020d12c07d4e6 to your computer and use it in GitHub Desktop.
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
/* | |
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