Example #1
0
        public Task<DynamicPlaylistResponse> ExecuteAsync(DynamicArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return ExecuteAsync<DynamicPlaylistResponse>(argument.ToString());
        }
Example #2
0
        public DynamicPlaylistResponse Execute(DynamicArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return Execute<DynamicPlaylistResponse>(argument.ToString());
        }
Example #3
0
        public DynamicPlaylistResponse Execute(DynamicArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(Execute <DynamicPlaylistResponse>(argument.ToString()));
        }
Example #4
0
        public Task <DynamicPlaylistResponse> ExecuteAsync(DynamicArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(ExecuteAsync <DynamicPlaylistResponse>(argument.ToString()));
        }
Example #5
0
        public void GetDynamicPlaylist_WhereMoodAndStyle_CanSteerDynamicPlaylistByMood(string title, string styles, string moods)
        {
            //arrange
            TermList styleTerms = new TermList();
            foreach (string s in styles.Split(','))
            {
                styleTerms.Add(s);
            }

            TermList moodTerms = new TermList();
            foreach (string s in moods.Split(','))
            {
                moodTerms.Add(s);
            }

            DynamicArgument dynamicArgument = new DynamicArgument
            {
                Adventurousness = 0.4,
                Type = "artist-description",
                Variety = 0.4 /* variety of artists */
            };

            dynamicArgument.Styles.AddRange(styleTerms);

            dynamicArgument.Moods.AddRange(moodTerms);

            //act
            using (EchoNestSession session = new EchoNestSession(ConfigurationManager.AppSettings.Get("echoNestApiKey")))
            {
                //act
                DynamicPlaylistResponse searchResponse = session.Query<Dynamic>().Execute(dynamicArgument);

                //assert
                Assert.IsNotNull(searchResponse);
                Assert.IsNotNull(searchResponse.Songs);
                Assert.IsTrue(searchResponse.Songs.Any());

                // arrange next part of test
                string sessionId = searchResponse.SessionId;

                // output
                Console.WriteLine("Dynamic Playlist Session Id: {0}", sessionId);
                Console.WriteLine();
                Console.WriteLine("Songs for : {0}", title);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    Console.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }
                Console.WriteLine();
                Console.WriteLine("Steering Playlist by mood = -happy");
                Console.WriteLine();

                dynamicArgument = new DynamicArgument { SteerMood = "-happy", SessionId = sessionId };
                searchResponse = session.Query<Dynamic>().Execute(dynamicArgument);
                Console.WriteLine("Next song in dynamic playlist for : {0}", title);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    Console.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }

                Console.WriteLine();
                Console.WriteLine("Steering Playlist by tempo = +10% (tempo^1.1)");
                Console.WriteLine();
                dynamicArgument = new DynamicArgument { Steer = "tempo^1.1", SessionId = sessionId };
                searchResponse = session.Query<Dynamic>().Execute(dynamicArgument);
                Console.WriteLine("Next song in dynamic playlist for : {0}", title);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    Console.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }
                Console.WriteLine();
            }
        }