Welcome Guest, [ Sign In | Create An Account ]
 Browse

Artists

Song Names
Albums
Advertisements
Friends

© Copyright 2003 Leo's Lyrics.
All Rights Reserved.

 
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing  
LeosLyrics API  XML
Forum Index -> Lyrics Plugin
Author Message
gatoradedrinker



Joined: 27/02/2007 21:12:27
Messages: 1
Offline

Is there an API around for Leo's site?

For instance, I am working on a program which could download the lyrics for a song, and then search those lyrics for playability on a radio station. I would need to know how to access the search and lyrics retrieval on the site.
LeosPluginGuy



Joined: 27/02/2007 21:12:27
Messages: 182
Offline

Send an email to leo@leoslyrics.com...I can't guarantee a fast response, but he'll get back to you eventually.
giacomolg



Joined: 30/07/2007 11:43:55
Messages: 2
Offline

Same request here, is there a API available...I guess so since Rhythmbox (http://www.gnome.org/projects/rhythmbox) uses it for lyrics retrival.
bentangle


[Avatar]

Joined: 02/08/2007 08:07:24
Messages: 12
Offline

I found this on the web. It helped me figure out how to query the database.
Enjoy
Bent

I recently wrote <slash type="file" id="6f18320df59806a66b37e6a7c0d660bd" title="The complete script">a simple bash script</slash> to incorporate a lyrics database into some of my music-handling scripts. I took advantage of one of the benefits of open source software by finding an existing application that performed this task and inspecting the code to see how the developers did it.
I started with the code for Rhythmbox, a music management application. I discovered that the developers used a couple of simple URL calls to a Web-based lyrics database called Leo's Lyrics:

http://api.leoslyrics.com/api_search.php?auth=duane&artist=cake&songtitle=comfort eagle
http://api.leoslyrics.com/api_lyrics.php?auth=duane&hid=VxwOBYpM3iY=
The first call returns an XML file containing the results of the search in a file like the one below. (Note: the authorization token [I use "duane"] seems to be ignored by the server. I tried unsuccessfully to find some documentation for the Web-based API on the Web site. I also tried sending an email to the support address on the site after signing up for an account that allows you to submit new lyrics, but I got no response.)

<?xml version="1.0" encoding="UTF-8"?>
<leoslyrics>
<response code="0">SUCCESS</response>
<searchResults>
<result id="120741" hid="VxwOBYpM3iY=" exactMatch="true">
<title>Comfort Eagle</title>
<feat/>
<artist>
<name>Cake</name>
</artist>
</result>
</searchResults>
</leoslyrics>
From the response element (<response code="0">SUCCESS</response>) I could see that the call had succeeded. The next thing I was interested in was the result element (<result id="120741" hid="VxwOBYpM3iY=" exactMatch="true">), and particularly in the hid attribute, which is the id of the lyric entry that I was interested in. I passed the hid that I gleaned to the second URL call, and got this result:

<?xml version="1.0" encoding="UTF-8"?>
<leoslyrics>
<response code="0">SUCCESS</response>
<lyric hid="VxwOBYpM3iY=" id="120741">
<title>Comfort Eagle</title>
<feat/>
<artist>
<name>Cake</name>
</artist>
<albums>
<album>
<name>Comfort Eagle</name>
<imageUrl>http://images.amazon.com/images/P/B00005MCW5.01.MZZZZZZZ.jpg</imageUrl>
</album>
</albums>
<writer/>
<text>We are building a religion
We are building it bigger
.................
Pendant keychains</text>
</lyric>
</leoslyrics>
From these results I saw that I could pull out the text element (<text>.../<text>) from the results and have my song lyrics.

To automate this process in a bash script I used wget and xmlstarlet. Wget is a simple utility for non-interactive download of files from the Internet. I used wget to call the URLs with the correct parameters and capture the XML results. Xmlstarlet is a set of command-line utilities used to query and process XML documents. I used xmlstarlet to pull out the pertinent information from the URL call results.

To make this script really useful, I wanted to supply it with a path to an MP3 file and have it pull the artist and title from the ID3 tag in the file and use this information to download the lyrics. I used id3tool, a utility that can view and edit ID3 tags within MP3 files from the command line.

After running id3tool at the start of the script, I use sed to pull the artist information from id3tool's output and store it in a shell variable called ARTIST. I retrieve the song title with a similar line.

ARTIST=`id3tool "$1" | sed -ne "s/.*Artist:\(.*\)/\1/p"`
I then use wget to call a URL with the artist and title parameters. The call returns XML results which are stored in a shell variable called search_results:

search_results=`wget -q "http://api.leoslyrics.com/api_search.php?auth=$AUTH&artist=$ARTIST&songtitle=$SONGTITLE" -O -`
Next, I use xmlstarlet to parse information from the XML results. The following example executes the sel command of the xmlstarlet utility to parse the text of the response element:

result=`echo $search_results | xmlstarlet sel -t -v "/leoslyrics/response/text()"`
Finally, I use a combination of the technique above with the unesc command of the xmlstarlet utility, which simply un-escapes all escaped characters in the text, making it easier to read:

echo $lyrics | xmlstarlet sel -t -v "/leoslyrics/lyric/text/text()" | xmlstarlet unesc > "$1.txt"
The completed script gets the lyrics for one song at a time. To download the lyrics for your entire song library, you can use the find command with the exec parameter to execute the script on all of your songs at once. For example, if your song library is rooted at /share/music/, you could run:

find /share/music/ -iname *.mp3 -exec get_lyrics.sh {} \;
You can easily use the same URL calls and response parsing techniques in your language of choice (providing that language can retrieve Web pages and parse XML). These techniques could also be adapted to work with other lyrics databases that support Web-based APIs. 



Bent Angle TV

[WWW]
bentangle


[Avatar]

Joined: 02/08/2007 08:07:24
Messages: 12
Offline

Since the main link broke I post it again....

http://api.leoslyrics.com/api_search.php?auth=duane&artist=cake&songtitle=comfort%20eagle

you see the "songtitle" and "artist" in the query string right?
this returns an XML doc, parse the doc for the value of the "hid" attribute in the result element...

then use that "hid" value to get the next XML (with the lyrics) from...

http://api.leoslyrics.com/api_lyrics.php?auth=duane&hid=VxwOBYpM3iY=

Parse that XML for the value of the "text" element....

I wrote some C#.net code to do the work.

Bent
[WWW]
giacomolg



Joined: 30/07/2007 11:43:55
Messages: 2
Offline

Thanks a lot, that is exactly what I was looking for

EDIT: what about the auth param? Can I simply use "duane" or I should request a new username?
bentangle


[Avatar]

Joined: 02/08/2007 08:07:24
Messages: 12
Offline

The Api is down today(or since who knows how long ago) So the link examples do not work right now.(nor any code built with them)

I hope it gets fixed soon =/


Bent Angle TV

[WWW]
bentangle


[Avatar]

Joined: 02/08/2007 08:07:24
Messages: 12
Offline

bentangle wrote:

I hope it gets fixed soon =/ 




Everything is back to working....


Bent Angle TV

[WWW]
tjpoe



Joined: 27/02/2007 21:12:27
Messages: 7
Offline

the following api url: http://api.leoslyrics.com/api_search.php?auth=duane&hid=VxwOBYpM3iY=

retrieves the following:
<leoslyrics>
<response code="0">SUCCESS</response>
<searchResults/>
</leoslyrics>
rblask



Joined: 12/01/2008 23:59:53
Messages: 1
Offline

http://lyricsfly.com/api/

Personally I like lyricsfly and they have the API also
Farthen



Joined: 26/02/2009 12:43:20
Messages: 1
Offline

Sorry to reply to this old thread...

How did you get the line breaks? They are not included in the xml are they?

Thanks
 
Forum Index -> Lyrics Plugin
Go to:   
Powered by JForum 2.1.7 © JForum Team