Create your own Music Lyric Search Engine in 1 Minute

Everyone loves Music and i'm sure that everyone has searched for a lyric of a song before. Right? Right. So why not build a lyric search for your own website? Too complicated? No way. I show you how you can build your own Music Search Engine with less than 20 lines of code - using the API of the awesome Lyricwiki.org Website. With these few lines you can search for over 680.000 Lyrics. So lets go - here is the code:

The Code...

$artist = $_GET["artist"]; //get your artist
$song = $_GET["song"]; //get your song
$artist = str_replace(" ", "_", $artist); //Replace spaces with_
$song = str_replace(" ", "_", $song); //Replace spaces with_
<!--Now a simple HTML Form with artist and song fields -->
<form action="<?php $_SERVER["PHP_SELF"];?>" method="get">
<label for="artist">Artist:</label>
<input type="text" name="artist" value="<?php echo $artist;?>" id="artist" />
<label for="song">Songname:</label>
<input type="text" name="song" value="<?php echo $song;?>" id="song"/>
<input type="submit" value="search"/>
</form>
// The important part-get the Lyric from the Lyricwiki.org API
$info = file_get_contents("http://lyricwiki.org/api.php?artist=".$artist."&song=".$song."&fmt=text");
echo nl2br($info); //echo our searched lyrics

Example

Check out the Example of this script. If you just enter an Artist and no Song name, all songs of the found Artist will be displayed! Cool stuff!

Download the Code

Grab this script and use it as you want - a backlink to kollermedia.at would be awesome of course :)

  Music Lyric Search Engine (703 bytes, 591 hits)


 

10 Kommentare »

verfasst am 4. Juli 2008 um 0:58

I was looking for something like this! This is perfect. Thanks so much!

James
verfasst am 15. August 2008 um 4:46

I was looking for an example of how to implement the api at lyricwiki and this looks great except that when I try to search a song name nothing comes up. Was there an update on the lyricwiki api which disallows this implementation?

Also I tried searching for a recent artist and nothing comes up but when you search on the lyricwiki website it comes up. I don't really know why this is happening.

If you could help me with implementing the api it would be greatly appreciated.

Thank you,
James

verfasst am 15. August 2008 um 10:45

Hi James,
it still does work.

Just try Mariah Carey and click search.
Or try Mariah Carey and Alone in Love

If you search for a Song you always have to enter an artist & the song name.

Pet
verfasst am 10. September 2009 um 6:58

Hi!
Ich habe dieses Script für meine Webseite benutzt. Leider habe ich festgestellt, dass sie nicht mehr funktioniert.
Anscheinend hat Wiki änderungen vorgenommen.
Könntest Du mir bitte sagen was ich jetzt ändern muss?
Ich habe sehr wenig erfahrung mit Scripting! (Newbee :( )
Ich danke Dir im voraus.

verfasst am 10. September 2009 um 8:08

Hi, ja du hast recht leider wurde dort die API verändert - man bekommt von dort jetzt leider keine lyrics mehr - also helfen auch Änderungen am code leider nichts.

verfasst am 12. September 2009 um 2:45

Tja, dann ist es dumm gelaufen.
Auf jeden fall, möchte ich mich für deine tolle Beiträge bedanken.

LG. Pet

verfasst am 11. September 2009 um 0:21

Hi! I was surfing and found your blog post... nice! I love your blog. :) Cheers! Sandra. R.

Webnessie
verfasst am 11. September 2009 um 23:18

hallo,

gibt es ein update für das script ?

vielen dank im voraus

verfasst am 10. Oktober 2011 um 13:21

Thank for your best code

verfasst am 10. Oktober 2011 um 13:26

Thanks

Kommentar schreiben

(erforderlich)

(required but will not be published)

(if you have one)

Bild einfügen:<img src="http://www.website.com/meinbild.jpg" alt="bildbeschreibung" />


 
Produced and © by Koller Jürgen | Powered by the awesome WP | Love and Joy to everyone