Beispiel #1
0
        public Task<PlaylistResponse> ExecuteAsync(StaticArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return ExecuteAsync<PlaylistResponse>(argument.ToString());
        }
Beispiel #2
0
        public Task <PlaylistResponse> ExecuteAsync(StaticArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(ExecuteAsync <PlaylistResponse>(argument.ToString()));
        }
Beispiel #3
0
        public PlaylistResponse Execute(StaticArgument argument)
        {
            argument.ApiKey = ApiKey;
            argument.BaseUrl = Url;

            return Execute<PlaylistResponse>(argument.ToString());
        }
Beispiel #4
0
        public PlaylistResponse Execute(StaticArgument argument)
        {
            argument.ApiKey  = ApiKey;
            argument.BaseUrl = Url;

            return(Execute <PlaylistResponse>(argument.ToString()));
        }
 public StyleTrackStream(
     StaticArgument argument,
     IRadio radio,
     IToastService toastService)
 {
     _argument = argument;
     _radio = radio;
     _toastService = toastService;
 }
        private PlaylistResponse GetSongPlaylist(EchoNestSession session, string query)
        {
            var id = GetSongId(session, query);
            var songIds = new TermList();
            songIds.Add(id);

            StaticArgument staticArgument = new StaticArgument
            {
                Type = "song-radio",
                SongID = songIds,
                Results = 40,
                Variety = 1
            };

            return session.Query<Static>().Execute(staticArgument);
        }
        public void GetStaticPlaylist_WhereMoodAndStyle_HasVarietyOfArtists(string title, string styles, string moods)
        {
            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);
            }

            StaticArgument staticArgument = new StaticArgument
            {
                Results = 25,
                Adventurousness = 0.4,
                Type = "artist-description",
                Variety = 0.4 /* variety of artists */
            };

            staticArgument.Styles.AddRange(styleTerms);

            staticArgument.Moods.AddRange(moodTerms);

            using (EchoNestSession session = new EchoNestSession(ConfigurationManager.AppSettings.Get("echoNestApiKey")))
            {
                PlaylistResponse searchResponse = session.Query<Static>().Execute(staticArgument);

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

                Console.WriteLine("Songs for : {0}", title);
                foreach (SongBucketItem song in searchResponse.Songs)
                {
                    Console.WriteLine("\t{0} ({1})", song.Title, song.ArtistName);
                }

                Console.WriteLine();
            }
        }
        private PlaylistData CreateEchonestPlaylist(string apiKey)
        {
            var seedArtists = new TermList();

            seedArtists.Add(Query);

            StaticArgument staticArgument = new StaticArgument
            {
                Results = 40,
                Artist = seedArtists,
                Type = "artist-radio"
            };

            using (var session = new EchoNestSession(apiKey))
            {
                PlaylistResponse searchResponse = session.Query<Static>().Execute(staticArgument);
                var playlistData = new PlaylistData();
                playlistData.Items = new List<PlaylistDataItem>();
                playlistData.Description = Query;
                playlistData.Title = string.Format("{0} playlist", Query);
                playlistData.SearchKeys = new List<string>();

                foreach (var song in searchResponse.Songs)
                {
                    var item = new PlaylistDataItem();
                    item.Artist = song.ArtistName;
                    item.Title = song.Title;
                    playlistData.Items.Add(item);

                    var searchKey = string.Format("{0} {1}", item.Artist, item.Title);
                    playlistData.SearchKeys.Add(searchKey);
                }

                return playlistData;
            }
        }
Beispiel #9
0
        public void GetPlaylistByArtistOrSong(string query)
        {
            var seedArtists = new TermList();
            seedArtists.Add(query);

            StaticArgument staticArgument = new StaticArgument
            {
                Results = 40,
                Artist = seedArtists,
                Type = "artist-radio"
            };

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

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

                Assert.AreEqual(40, searchResponse.Songs.Count);
            }
        }
Beispiel #10
0
        public void GetFourtyRunningSongs(string query)
        {
            var id = GetSongId(query);
            var songIds = new TermList();
            songIds.Add(id);

            StaticArgument staticArgument = new StaticArgument
            {
                Type = "song-radio",
                SongID = songIds,
                Results = 40,
                MinTempo = 88,
                MaxTempo = 92,
                Variety = 1
            };
                

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

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

                Assert.AreEqual(40, searchResponse.Songs.Count);
            }
        }
        private PlaylistResponse GetArtistPlaylist(EchoNestSession session, string query)
        {
            
            var seedArtists = new TermList();

            foreach (var term in query.Split(','))
            {
                seedArtists.Add(term);
            }

            StaticArgument staticArgument = new StaticArgument
            {
                Results = 40,
                Artist = seedArtists,
                Type = "artist-radio"
            };

            return session.Query<Static>().Execute(staticArgument);
        }
        private void ExecuteStartRadio()
        {
            Task.Factory.StartNew(() =>
            {
                SelectedMoods.ForEach(s => s.Count = s.Count + 1);
                SelectedStyles.ForEach(s => s.Count = s.Count + 1);

                using (var session = _documentStore.OpenSession())
                {
                    foreach (var selectedStyle in SelectedStyles)
                    {
                        var styleTerm = session.Load<StyleTerm>(selectedStyle.ID);

                        if (styleTerm != null)
                        {
                            styleTerm.Count = selectedStyle.Count;
                            session.Store(styleTerm);
                        }
                    }

                    foreach (var selectedMood in SelectedMoods)
                    {
                        var styleTerm = session.Load<MoodTerm>(selectedMood.ID);

                        if (styleTerm != null)
                        {
                            styleTerm.Count = selectedMood.Count;
                            session.Store(styleTerm);
                        }
                    }

                    session.SaveChanges();
                }
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    _logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });

            Task.Factory.StartNew(() =>
            {
                using (_loadingIndicatorService.EnterLoadingBlock())
                {
                    using (var session = new EchoNestSession(EchoNestModule.ApiKey))
                    {
                        SearchArgument arg = new SearchArgument();
                        FillTermList(SelectedMoods, arg.Moods);
                        FillTermList(SelectedStyles, arg.Styles);
                        arg.MinFamiliarity = ArtistFamiliarity.Minimum;
                        arg.MinHotttnesss = ArtistHotness.Minimum;

                        var response = session.Query<Search>().Execute(arg);

                        if (response == null)
                        {
                            _toastService.Show("Unable to generate playlist");
                            return;
                        }

                        if (response.Status.Code == ResponseCode.Success && response.Artists.Count > 0)
                        {
                            StaticArgument arg2 = new StaticArgument();
                            arg2.Results = 75;
                            FillTermList(SelectedMoods, arg2.Moods);
                            FillTermList(SelectedStyles, arg2.Styles);
                            arg2.Type = "artist-radio";
                            arg2.Artist.Add(response.Artists[0].Name);
                            arg2.MinTempo = Tempo.Minimum;
                            arg2.MinLoudness = Loudness.Minimum;
                            arg2.MinDanceability = Danceability.Minimum;
                            arg2.MinEnergy = Energy.Minimum;
                            arg2.ArtistMinFamiliarity = ArtistFamiliarity.Minimum;
                            arg2.ArtistMinHotttnesss = ArtistHotness.Minimum;
                            arg2.SongMinHotttnesss = SongHotness.Minimum;

                            _radio.Play(new StyleTrackStream(arg2, _radio, _toastService));
                        }
                        else
                        {
                            if (response.Artists != null && response.Artists.Count == 0)
                            {
                                // TODO : Localize
                                _toastService.Show("Unable to find songs matching the current criterias");
                            }
                            else
                            {
                                _toastService.Show("EchoNest : " + response.Status.Message);
                            }
                        }
                    }
                }
            })
            .ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    _logger.Log(task.Exception.ToString(), Category.Exception, Priority.Medium);
                }
            });
        }