Esempio n. 1
0
        private void OnAddArtist(object o, EventArgs args)
        {
            ArtistAdder editor = new ArtistAdder();

            // Add OnArtistAdditionResponse to the list of event handlers
            // for the artist adder.
            editor.Response += OnArtistAdditionResponse;
            editor.Show();
        }
Esempio n. 2
0
        private void OnArtistAdditionResponse(object o, ResponseArgs args)
        {
            ArtistAdder editor  = (ArtistAdder)o;
            bool        destroy = true;

            try {
                if (args.ResponseId == ResponseType.Ok)
                {
                    if (String.IsNullOrEmpty(editor.ArtistName))
                    {
                        destroy             = false;
                        editor.ErrorMessage = Catalog.GetString("Please provide a artist name");
                    }
                    else
                    {
                        JsonArray results = IO.MakeRequest("people", editor.ArtistName);

                        foreach (JsonObject artist in results)
                        {
                            string artist_name = (string)artist["username"];
                            if (artist_name == editor.ArtistName)
                            {
                                //SC.log(artist.ToString());
                                JsonArray tracks = IO.MakeRequest("getalltracks",
                                                                  (int)artist["id"]);
                                //SC.log(tracks.ToString());
                                SC.log(String.Format("Artist: {0}, Track Count: {1}",
                                                     artist_name, tracks.Count));

                                foreach (JsonObject t in tracks)
                                {
                                    DatabaseTrackInfo track = IO.makeTrackInfo(t);
                                    track.PrimarySource = this;
                                    track.IsLive        = true;
                                    track.Save();
                                    SC.log("  added track: " + track.TrackTitle);
                                }
                            }
                        }
                        // If all is well, set the window to close.
                        destroy = true;
                    }
                }
            } finally {
                if (destroy)
                {
                    // Remove response-handler reference.
                    editor.Response -= OnArtistAdditionResponse;
                    editor.Destroy();
                }
            }
        }
 private void OnAddArtist(object o, EventArgs args)
 {
     ArtistAdder editor = new ArtistAdder();
     // Add OnArtistAdditionResponse to the list of event handlers
     // for the artist adder.
     editor.Response += OnArtistAdditionResponse;
     editor.Show();
 }