static void Main(string[] args) { //fill credentials SoundCloudCredentials credentials = new SoundCloudCredentials(ClientId, ClientSecret, Username, Password); //create client SoundCloudClient client = new SoundCloudClient(credentials); //login to soundcloud SoundCloudAccessToken token = client.Authenticate(); //fetch some data if (client.IsAuthenticated) { //Fetch current user info var mySelf = User.Me(); //search for tracks string searchFor = "electro swing"; //execute search List <Track> searchResults = Track.Search(searchFor, null, Filter.All, "", "", null, null, null, null, DateTime.MinValue, DateTime.Now, null, null, null); //iterate in tracks and fetch details again foreach (int trackId in searchResults.Select(track => track.Id)) { Track track = Track.GetTrack(trackId); //here you can play a track or do something else ;) } } //wait for user input Console.ReadLine(); }
private void Button_Click(object sender, RoutedEventArgs e) { var username = this.Username.Text; var passwrod = this.Password.Password; new Thread(() => { var credentials = new SoundCloudCredentials(ClientId, ClientSecret, username, passwrod); var client = new SoundCloudClient(credentials); SoundCloudAccessToken token = null; try { token = client.Authenticate(); } catch (Exception) { MessageBox.Show("login failed."); return; } var downloader = new Downloader(ClientId, token.AccessToken); //fetch some data if (client.IsAuthenticated) { //Fetch current user info var mySelf = User.Me(); var clientID = client.getClientID(); var trackList = new List <Track>(); var i = 1; var limit = 200; var favorites = User.Me().GetFavorites(limit, 1); while (favorites.NextHref != null) { foreach (var favorite in favorites.Tracks) { var track = Track.GetTrack(favorite.Id); if (downloader.DownloadMusicWithTrackId(track)) { ListView1.Dispatcher.Invoke( new Action(() => { _likeCollection.Add(new Like() { Index = i++, Title = track.Title }); })); } } favorites = JsonSerializer.Deserialize <Favorite>(new WebClient() { Encoding = new UTF8Encoding() }.DownloadString(favorites.NextHref)); } MessageBox.Show("download successfully finished."); } }).Start(); }