예제 #1
0
        public async Task <SearchingResult> Search_Artists(string search)
        {
            try
            {
                searchingResult = new SearchingResult();
                HttpClient          httpClient          = new HttpClient();
                String              adress              = lastFMLink + search + lastFmApiKey;
                HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(new Uri(adress));

                String s = await httpResponseMessage.Content.ReadAsStringAsync();

                dynamic spotify = JsonConvert.DeserializeObject(s);
                dynamic artist  = spotify["toptracks"];
                dynamic items   = artist["track"];
                searchingResult.Artist = search;


                foreach (var track in items)
                {
                    Track newTrack = new Track();
                    //oreach (var info in track["album"])
                    {
                        newTrack.PhotoUrl = track["image"][2]["#text"];
                        newTrack.Name     = track["name"];
                        searchingResult.Tracks.Add(newTrack);
                    }
                }
            }
            catch (Exception e)
            {
                Poruka = new MessageDialog(e.Message);
                await Poruka.ShowAsync();
            }
            return(searchingResult);
        }
예제 #2
0
        public async Task <SearchingResult> Search_Artists(string search)
        {
            //try
            {
                searchingResult = new SearchingResult();
                HttpClient          httpClient          = new HttpClient();
                String              adress              = SpotifyGET + search + SpotifyGETArtist;
                HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(new Uri(adress));

                String s = await httpResponseMessage.Content.ReadAsStringAsync();

                dynamic spotify = JsonConvert.DeserializeObject(s);
                dynamic artist  = spotify["artists"];
                dynamic items   = artist["items"];
                searchingResult.Artist = items[0]["name"];

                String artistID = items[0]["id"];
                httpClient          = new HttpClient();
                adress              = SpotifyGETTracks + artistID + SpotifyGETTracksAdd;
                httpResponseMessage = await httpClient.GetAsync(new Uri(adress));

                s = await httpResponseMessage.Content.ReadAsStringAsync();

                spotify = JsonConvert.DeserializeObject(s);
                dynamic tracks = spotify["tracks"];
                foreach (var track in tracks)
                {
                    Track newTrack = new Track();
                    //oreach (var info in track["album"])
                    {
                        newTrack.PhotoUrl = track["album"]["images"][0]["url"];
                        newTrack.Preview  = track["preview_url"];
                        newTrack.Name     = track["name"];
                        searchingResult.Tracks.Add(newTrack);
                    }
                }
            }
            //catch(Exception e)
            {
                // Poruka = new MessageDialog(e.Message);
                //await Poruka.ShowAsync();
            }
            return(searchingResult);
        }
예제 #3
0
 public PretragaMuzike()
 {
     searchingResult = new SearchingResult();
 }
예제 #4
0
 public LastFmPretraga()
 {
     searchingResult = new SearchingResult();
 }