C# .NET and LyricWiki to lookup lyrics

Music is everywhere with today’s high speed internet is most home it is no wonder that music is even moving to the World Wide Web. Many radio stations allow you to stream their stations over the internet. Many websites have been developed around music, like www.jango.com, www.pandora.com, and www.last.fm. I recently released my second version of Jango Desktop and one of the features I implemented was the ability to look up lyrics. Before I started I was thinking about all the ways I could parse the lyrics out of an existing lyric’s websites database. During my searching I stumbled upon http://lyricwiki.org/. Here is a small description of LyricWiki from the website:

LyricWiki is a free site which is a source where anyone can go to get reliable lyrics for any song, from any artist, without being hammered by invasive ads.

At this point you are probably thinking to yourself the same thing I did “Great, but where do I start?” So today I am writing a step by step tutorial on how to use Lyric wiki in your .NET program.

Creating a simple lyric demo program:

Step 1 Create the Form

Step 1: Create the Form

Open visual studio and setup your form to look similar to mine.

Adding the web service:

Because LyricWiki offers a web service, you will want to add it to your program as a web reference. Right click on your solution and select add a web reference, or in .net 3.5 add a service reference -> then go to advance and add a web reference. The service’s URL is http://lyricwiki.org/server.php?wsdl you will want to add it like below if you press go you should see the available methods.

Adding a Web Reference

Adding a Web Reference

Writing the code:

Double click on your button on the form and let’s right some code to handle the lookup.

Add this to the top of your code:


using LyricsLookup.org.lyricwiki;

Then add this to the button clicked method:


private void LyricsButton_Click(object sender, EventArgs e)

{

LyricWiki wiki = new LyricWiki();

LyricsResult result;

string artist = artistTextBox.Text;

string song =   SongTextBox.Text;

if(wiki.checkSongExists(artist,song))

{

result = wiki.getSong(artist, song);

Encoding iso8859 = Encoding.GetEncoding("ISO-8859-1");

LyricsRichTextBox.Text = Encoding.UTF8.GetString(iso8859.GetBytes(result.lyrics));

}else{

StatusLabel.Text = "Lyrics not found in database";

}

}

Then run and test.

Download the full solution of LyricsLookup

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Slashdot
  • MySpace
  • StumbleUpon
  • Tumblr
  • Twitter
  • email
  • Print

Tags: , , ,

Sunday, March 22nd, 2009 Desktop Enginnering, Programming, Software

10 Comments to C# .NET and LyricWiki to lookup lyrics

  • Claton says:

    Hey..

    Excellent code.. but am getting an Error in
    result = wiki.getSong(artist, song);

    Error: Response is not a well formed XML

    I even downloaded your code..but still face the same issue..
    am using VS2008 & C#..
    any help is appreciated..

    regards,
    Claton

  • FernandoJS says:

    Hi,

    This example run perfect here…but the method “getartist” is fail.

    Do you tested the getartist?

    Thanks

  • Claton says:

    After struggling a lot I was able to figure out that “Response is not a well formed XML” Error relates to Proxy setting, if you play around with your Proxy settings. The tool would work.

    Hope this helps for others …

    Regards,
    Claton

  • Samuel Haddad says:

    After reading your post. I played around with this a little and wasn’t able to get it to work either. Interestingly though if you use Fiddler you can see that you actually do get the results back. I will investigate this more when I have a chance.

  • Matt says:

    The service is no longer available. The message you get back with trying to interact with the service is that it’s been shut down due to legal issues.

    Anyone have another source just like this one? I’ve been trying to create a lyrics gathering program but can’t find a good, free web service to do it with.

  • Samuel Haddad says:

    You right, LyricWiki discounted their lyrics service. You can read about it here: http://groups.google.com/group/lyricwiki-api/browse_thread/thread/733ccd919d654040

  • omer arslan says:

    hi all, why cant i reach whole of a lyrics when i get it by getsong(). for instance i try to get the eminem – without me.
    the result is below, where is the rest of the lyrics, it ends with [...], is there a problem of lisancing?…

    ”’Obie Trice”’
    “Obie Trice, Real Name No Gimmicks…”

    ”’Eminem”’
    Two trailer park girls go round the outside,
    round the outside, round the outside.
    Two trailer park girls go round the outside,
    round the outside, round the outside.

    ”’Female Voice”’
    “Ooooohhhhh!”

    ”’Eminem”’
    Guess who’s back, back, back
    back again, gain, gain
    Shadys back, back, back
    tell a friend
    Guess who’s back, guess who’s back,
    guess who’s back, guess who’s back,
    guess who’s back, guess who’s back,
    guess who’s back… la la la

    I’ve created a monster, cuz nobody wants to
    See Marshall no more they[...]

  • Samuel Haddad says:

    What code are you using? I thought the service was shut down.

  • tincek says:

    same problem here, i get [...] at the end of every lyrics.

  • blah says:

    They won’t allow you to get the full lyrics due to licensing issues. However with their service you can get the url for the lyrics. You can get the full lyrics if you parse the html downloaded from the url they give you.

  • Leave a Reply