Return to Snippet

Revision: 35182
at November 3, 2010 23:13 by fenfe1


Updated Code
if (trackName != null && artistName != null)
            {
                //Get track info

                LastFmLib.API20.Types.Track suspect = new LastFmLib.API20.Types.Track();
                //LastFmLib.API20.Types.ArtistInfo suspectArtist = new LastFmLib.API20.Types.ArtistInfo();
                //suspectArtist.Name = "something";
                suspect.Artist = new LastFmLib.API20.Types.ArtistInfo(suspect.Artist.Name = artistName);
                suspect.Title = trackName;
                try
                {
                    
                    LastFmLib.API20.Tracks.TrackSearch detective = new LastFmLib.API20.Tracks.TrackSearch(suspect);
                    //detective.Limit = 1;

                    detective.Start();
                    if (detective.succeeded)
                    {
                        //for now just list the results
                        foreach (LastFmLib.API20.Types.Track sparkle in detective.Result.Tracks)
                        {
                            Console.WriteLine();
                            Console.WriteLine("And the result is: A: " + sparkle.ArtistName + " T: " + sparkle.Title + " L: " + sparkle.NumListeners);
                            Console.WriteLine();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine();
                    Console.WriteLine("Error: {0}", e.ToString());
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;
                }
                
                Console.WriteLine("Something good should happen here");
                Console.WriteLine("Artist: " + artistName + " Track: " + trackName);
            }
            else
            {
                //Give error
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(">< Error: Not enough track data was provided ><");
                Console.ForegroundColor = ConsoleColor.White;
                if (debug)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("The track name or artist name were missing.");
                    Console.WriteLine("Please check the output of the XML.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }

Revision: 35181
at November 3, 2010 23:11 by fenfe1


Initial Code
//Get track info

                LastFmLib.API20.Types.Track suspect = new LastFmLib.API20.Types.Track();
                //LastFmLib.API20.Types.ArtistInfo suspectArtist = new LastFmLib.API20.Types.ArtistInfo();
                //suspectArtist.Name = "something";
                suspect.Artist = new LastFmLib.API20.Types.ArtistInfo(suspect.Artist.Name = artistName);
                suspect.Title = trackName;
                try
                {
                    
                    LastFmLib.API20.Tracks.TrackSearch detective = new LastFmLib.API20.Tracks.TrackSearch(suspect);
                    //detective.Limit = 1;
                    //detective.RequestMode = LastFmLib.API20.modEnums.RequestMode.Rest;
                    
                    //LastFmLib.API20.Settings.DefaultLangCode = "en-gb";

                    //look at how its searching!

                    detective.Start();
                    if (detective.succeeded)
                    {
                        //for now just list the results
                        foreach (LastFmLib.API20.Types.Track sparkle in detective.Result.Tracks)
                        {
                            Console.WriteLine();
                            Console.WriteLine("And the result is: A: " + sparkle.ArtistName + " T: " + sparkle.Title + " L: " + sparkle.NumListeners);
                            Console.WriteLine();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine();
                    Console.WriteLine("Error: {0}", e.ToString());
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;
                }

Initial URL

                                

Initial Description

                                

Initial Title
PureScrobbler track search problem

Initial Tags

                                

Initial Language
C#