Example #1
0
    public static Dictionary<string, Song> FetchSongs(string response)
    {
        Dictionary<string, Song> songs = new Dictionary<string, Song>();
        IDictionary search = (IDictionary)Json.Deserialize(response);

        IDictionary response2 = (IDictionary)search["response"];
        IList songsresponse = (IList)response2["songs"];
        int i = 1;
        foreach (IDictionary s in songsresponse)
        {
            Song song = new Song();
            song.Artist = (string)s["artist_name"];
            song.Title = (string)s["title"];
            song.Init();
            if (!songs.ContainsKey(song.Key))
            {
                song.ChartPosition = i++;
                song.FetchPreviewUrl();
                songs.Add(song.Key, song);
            }
        }
        return songs;
    }