Exemplo n.º 1
0
        public void GetBasicPlaylist_WhereArtistName_HasSongsByArtist(string artistName)
        {
            //arrange
            BasicArgument basicArgument = new BasicArgument
            {
                Results = 10,
                Dmca = true
            };

            TermList artistTerms = new TermList { artistName };
            basicArgument.Artist.AddRange(artistTerms);

            //act
            using (EchoNestSession session = new EchoNestSession(ConfigurationManager.AppSettings.Get("echoNestApiKey")))
            {
               //act
                PlaylistResponse searchResponse = session.Query<Basic>().Execute(basicArgument);

                //assert
                Assert.IsNotNull(searchResponse);

                // output
                Console.WriteLine("Songs for : {0}", artistName);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    Console.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        public void GetBasicPlaylist_WhereArtistName_HasSongsByArtist(string artistName)
        {
            BasicArgument basicArgument = new BasicArgument
            {
                Results = 10,
                Dmca = true
            };

            TermList artistTerms = new TermList { artistName };
            basicArgument.Artist.AddRange(artistTerms);

            using (var session = new EchoNestSession(ApiKey))
            {
                PlaylistResponse searchResponse = session.Query<Basic>().Execute(basicArgument);

                Assert.IsNotNull(searchResponse);

                System.Diagnostics.Debug.WriteLine("Songs for : {0}", artistName);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    System.Diagnostics.Debug.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }

            }
        }
Exemplo n.º 3
0
        public Task<PlaylistResponse> ExecuteAsync(BasicArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return ExecuteAsync<PlaylistResponse>(argument.ToString());
        }
Exemplo n.º 4
0
        public PlaylistResponse Execute(BasicArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return Execute<PlaylistResponse>(argument.ToString());
        }
Exemplo n.º 5
0
        public Task <PlaylistResponse> ExecuteAsync(BasicArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(ExecuteAsync <PlaylistResponse>(argument.ToString()));
        }
Exemplo n.º 6
0
        public PlaylistResponse Execute(BasicArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(Execute <PlaylistResponse>(argument.ToString()));
        }
Exemplo n.º 7
0
        private static void Basic(EchoNestSession session)
        {
            String query = String.Empty;

            ConsoleEx.WriteLine("=== Basic Playlist Generation ===", ConsoleColor.Cyan);
            ConsoleEx.WriteLine("(Enter a comma separated list of artist names for generating a baisc 'artist-radio' type playlist)", ConsoleColor.Cyan);

            ConsoleEx.Write("Query >> ", ConsoleColor.Green);
            query = Console.ReadLine();

            if (String.IsNullOrEmpty(query))
            {
                ConsoleEx.WriteLine("Query was empty. Press any key to start over.", ConsoleColor.Cyan);
                Console.ReadLine();
                Basic(session);
            }

            ConsoleEx.WriteLine("Generating..", ConsoleColor.Yellow);

            BasicArgument basicArgument = new BasicArgument();

            string[] terms = query.Split(',');

            TermList artistTerms = new TermList();
            foreach (string term in terms)
            {
                artistTerms.Add(term.Trim());
            }

            basicArgument.Artist.AddRange(artistTerms);

            var result = session.Query<Basic>().Execute(basicArgument);

            if (result.Status.Code == ResponseCode.Success)
            {
                foreach (var item in result.Songs)
                {
                    ConsoleEx.Write("Artist: ", ConsoleColor.White);
                    ConsoleEx.WriteLine(item.ArtistName, ConsoleColor.DarkYellow);
                    ConsoleEx.Write("Hotttness: ", ConsoleColor.White);
                    ConsoleEx.WriteLine(item.ArtistHotttnesss.ToString(), ConsoleColor.DarkYellow);
                }
            }
            else
            {
                ConsoleEx.WriteLine(result.Status.Message, ConsoleColor.Red);
            }
        }