Пример #1
0
        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, IEncryptionManager encryption)
            : base(applicationPaths, xmlSerializer)
        {
            Instance    = this;
            _encryption = encryption;

            var username = Instance.Configuration.Username;
            var password = Instance.Configuration.PwData;

            var creds = new SoundCloudCredentials("78fd88dde7ebf8fdcad08106f6d56ab6",
                                                  "ef6b3dbe724eff1d03298c2e787a69bd");

            if (username != null && password != null)
            {
                creds = new SoundCloudCredentials("78fd88dde7ebf8fdcad08106f6d56ab6",
                                                  "ef6b3dbe724eff1d03298c2e787a69bd", username, _encryption.DecryptString(Instance.Configuration.PwData));
            }

            _SoundCloudClient = new SoundCloudClient(creds);

            if (username != null && password != null)
            {
                _SoundCloudClient.Authenticate();
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
 internal override void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     created_with?.AppendCredentialsToProperties(credentials);
     label?.AppendCredentialsToProperties(credentials);
     tracks.ForEach(x => x.AppendCredentialsToProperties(credentials));
     user?.AppendCredentialsToProperties(credentials);
     uri = uri.AppendCredentials(credentials);
 }
Пример #4
0
 internal override void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     created_with?.AppendCredentialsToProperties(credentials);
     label?.AppendCredentialsToProperties(credentials);
     stream_url = stream_url.AppendCredentials(credentials);
     uri        = uri.AppendCredentials(credentials);
     user?.AppendCredentialsToProperties(credentials);
     user_uri = user_uri.AppendCredentials(credentials);
 }
Пример #5
0
        public void Test_AppendCredentials_No_Credentials()
        {
            var credentials = new SoundCloudCredentials();

            var uri = new Uri("http://test.com/?");

            uri = uri.AppendCredentials(credentials);

            Assert.That(uri.ToString(), Is.EqualTo("http://test.com/?"));
        }
Пример #6
0
        public void Test_AppendCredentials_No_Query()
        {
            var credentials = new SoundCloudCredentials();

            credentials.ClientId = "clientId";

            var uri = new Uri("http://test.com/");

            uri = uri.AppendCredentials(credentials);

            Assert.That(uri.ToString(), Is.EqualTo("http://test.com/?client_id=clientId"));
        }
Пример #7
0
        public void Test_AppendCredentials_Ampersand_Delimiter()
        {
            var credentials = new SoundCloudCredentials();

            credentials.ClientId = "clientId";

            var uri = new Uri("http://test.com/?query=value");

            uri = uri.AppendCredentials(credentials);

            Assert.That(uri.ToString(), Is.EqualTo("http://test.com/?query=value&client_id=clientId"));
        }
Пример #8
0
        public void Test_AppendCredentials_AccessToken()
        {
            var credentials = new SoundCloudCredentials();

            credentials.AccessToken = "token";

            var uri = new Uri("http://test.com/?");

            uri = uri.AppendCredentials(credentials);

            Assert.That(uri.ToString(), Is.EqualTo("http://test.com/?oauth_token=token"));
        }
Пример #9
0
 internal Endpoint(ISoundCloudApiGateway gateway)
 {
     Credentials = new SoundCloudCredentials();
     Gateway     = gateway;
 }
Пример #10
0
 internal override void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     uri = uri.AppendCredentials(credentials);
 }
Пример #11
0
 internal abstract void AppendCredentialsToProperties(SoundCloudCredentials credentials);
        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();
        }
Пример #13
0
 internal override void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     origin?.AppendCredentialsToProperties(credentials);
 }
Пример #14
0
 internal override void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     subscriptions.ForEach(x => x.AppendCredentialsToProperties(credentials));
     uri = uri.AppendCredentials(credentials);
 }
Пример #15
0
 internal void AppendCredentialsToProperties(SoundCloudCredentials credentials)
 {
     future_href = future_href.AppendCredentials(credentials);
     next_href   = next_href.AppendCredentials(credentials);
 }