- Kollermedia.at - http://www.kollermedia.at -

Create your own Music Lyric Search Engine in 1 Minute

Posted By Jürgen Koller On 23. Juni 2008 @ 13:02 In Scripts etc. | 11 Comments

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 [1] 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 [2]. 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 [3] (703 bytes, 605 hits)


Article printed from Kollermedia.at: http://www.kollermedia.at

URL to article: http://www.kollermedia.at/archive/2008/06/23/create-your-own-music-lyric-search-engine-in-1-minute/

URLs in this post:

[1] Lyricwiki.org: http://www.lyricwiki.org

[2] Check out the Example of this script: http://www.kollermedia.at/wp-content/themes/kollermedia/specials/lyricengine/example.php

[3] Music Lyric Search Engine: http://www.kollermedia.at/download/8/

Copyright © Kollermedia.at. All rights reserved.