Tutorial: How to add a lyrics source

General discussions
Locked
tamalet
Posts: 490
Joined: Fri Sep 24, 2010 4:34 am

Tutorial: How to add a lyrics source

Post by tamalet »

This a simple tutorial on how to add the site http://www.lyricsvip.com as source, so people can learn how to add others and share them.

Before we start we should understand which lyrics sites can be added as sources and which cannot. The rule is simple: if there is an automatic way to get the whole URL to the lyrics from the tags of the track (artist, album, composer, genre, etc) then there is good chance that we can handle it, otherwise, if it includes some random data, we cannot.
For example, we can handle URLs like http://www.lyricsvip.com/Metallica/For- ... yrics.html, but we cannot handle http://www.lyricsfreak.com/p/pink+floyd ... 08779.html because of the random bits at the end.

Let's take www.lyricsvip.com as an example (not included in the default list, yet?).
Go to the lyrics tab and click on "Configure lyrics preferences".
Here you see two lists: Sources and Targets. The sources are where you get the lyrics from (embedded on the track, from a file, from the output of a command or from a website) and the targets are what you do with them (embed them on the track, save them to a file or send them to a command).

Now click on the + sign next to the sources.
In the lyrics source editor you can see several fields. Let's go one by one:

Name: this is the name of the source. Let's call it lyricsvip.com

Type: this is where we get the lyrics from. Change it to Download. A common mistake is to forget to change this.

Source: here we define a pattern to obtain the URL from the tags (to which we can later apply some replacements).
The available tag variables are:

{a} : Artist name
{al} : Artist in lower case
{au} : Artist in upper case
{a1} : First letter of artist
{as} : Artist first letter in upper and the rest in lower case
{b} : Album
{bl} : Album in lower case
{bu} : Album in upper case
{b1} : First letter of album
{bs} : Album first letter in upper and the rest in lower case
{t} : Title
{tl} : Title in lower case
{tu} : Title in upper case
{ts} : Title first letter in upper and the rest in lower case
{bp} : Album path
{f} : File name

Now we need to examine the URLs of the site. Unfortunately, case (capitals) matter!
In this case we see that it starts with http://www.lyricsvip.com/, then comes the artist, a slash, then the title and it ends in -Lyrics.htnl.
So the source is: http://www.lyricsvip.com/{a}/{t}-Lyrics.html

Replace: here we can specify how to translate some characters from the URL obtained with the previous pattern to obtain the URL from the site.
Usually the first thing one looks at are how spaces are translated. From our example we see that a space is translated to a dash. So lets add a new replace rule by clicking on the + sign next to the Replace box. In Search type just an space ‘ ‘ and in Replace type ‘-’. You will get the rule " -> -".
Then one should look at how the site handles each of the characteres _@,;&\/"'., letters with accents like áäåéëíïóöúüçñ, ß, etc. In this case we don't need to change them.
Note that in a replacement rule you can have many characters on the left of the arrow and each of them will be replaced by the character on the right of the arrow. (You can also write many characters on the right, but at the moment only the first character is used.)

Extract: here we have to say where to find the lyrics within the HTML page. Some basic knowledge of HTML would be helpful, but it's not really necessary.
Open the example page in a browser and look at its code (usually with Ctrl-u). Most of the times you can directly spot the lyrics, but sometimes it appears written with HTML codes. Any way it should be easy to find.
Then you need to find the enclosing HTML tag. In our example it's <table class="tbl0">. So add a new extract rule and put that on Begin. If you leave the End part empty it will extract up to the respective closing tag, </table> in our case. That's just what we want. Guayadeque will delete all the HTML code and the empty lines at the beginning and end of the lyrics for you. If you want to finish extracting at some other point, you can specify it on the End part of the rule.

Exclude: here you can define rules to exclude some text from the lyrics.
The lyrics from lyricsvip.com start with the song title and the artist. For example,
<h1>For Whom the Bell Tolls Lyrics</h1>
<h2>Metallica</h2>

Since we already know that information, we can exclude it. Just create two exclude rules, one whose Begin is <h1> and one with <h2>. As we don’t specify the End part of the rule, Guayadeque will delete to the corresponding </h1> and </h2> tags.

Not found: Some sites do not give a Page Not Found error if the address is incorrect, instead they return a page with an error message (see for instance http://letras.terra.com.br/winamp.php?m ... rtista=bbb). Here you can specify (part of) that message. There could be more than one error message.
It's not needed in our example.

Lets already do some tests. Click OK on the Source Lyrics Editor. The new source is added at end of the sources list. To try it check it and uncheck all the other sources. Also uncheck all the targets. Click on Accept and see how it works for you. It's recommended to run Guayadeque from the console so that you can see which URLs are tried. Then move it in the list of sources according the the priority you want to assign it and enable the other sources and targets you want to use.

Questions and comments are welcomed.
User avatar
anonbeat
Posts: 2048
Joined: Thu Sep 16, 2010 9:47 pm

Tutorial: How to add a lyrics source

Post by anonbeat »

Great tutorial tamalet. I could not explaing it better


great job
mekanix
Posts: 210
Joined: Wed Sep 29, 2010 11:20 pm

Tutorial: How to add a lyrics source

Post by mekanix »

Great Tutorial!!!

I'm trying to add DarkLyrics, it's probably the best site for metal lyrics (even for non-mainstream band).

Here the lyrics are organized in a different way, one page for each album.

So for example songs are delimited in this way:


1. Davidian


Blind man ask me forgiveness


I won't deny myself


Disrespect you have given


Your suffering's my wealth


I feed off pain, force fed to love it


And now I swallow whole


I'll never live in the past


Let freedom ring with a shotgun blast





Burn my fist to the concrete


My fear is my strength


Power, rage unbound because


Been pounded by the streets


Cyanide blood burns down the skyline


Hatred is purity


The bullet connects at last


Let freedom ring with a shotgun blast





Scarred


Pour the salt in the wound


Unscarred






2. Old


I am the man that defends all things profane


6000 years is the time that I shall reign


And with a grin drank the blood of holy swine


Impurity made the blood turn into wine





[Chorus:]


Old man, dead hand


If only their insanity


The lie feeds off their greed


Jesus wept





I am the pain that feeds off your weakness


A sickening born of hate, not of the blessed


And with the time I will crush all things you prey


Destroying all from the known to the arcane





[Chorus]





Burn my eyes and try to blind me


Bury me so they won't find me


Try to suck my power empty


Got no crown of thorns on me





So burn my eyes and try to blind me


Bury me so they won't find


Try to suck my power dry


You got no crown of thorns on me





[Chorus]








In the Extract field is is possible to use artist,album,tracks tags? or maybe to use just some wildcards (e.g. the *)?

Thanks
User avatar
anonbeat
Posts: 2048
Joined: Thu Sep 16, 2010 9:47 pm

Tutorial: How to add a lyrics source

Post by anonbeat »

No. Extract dont support tags. I checked Darklyrics and could not be done as it gives album lyrics instead of track lyrics.
camaron
Posts: 462
Joined: Sat Sep 25, 2010 3:38 am

Tutorial: How to add a lyrics source

Post by camaron »

Great job tamalet, thanks very much for the efford. I will put it into practice.

If someone else manage to add other sources they could share them here?
mekanix
Posts: 210
Joined: Wed Sep 29, 2010 11:20 pm

Tutorial: How to add a lyrics source

Post by mekanix »

Ok! Thanks for the clarification Anonbeat!
tamalet
Posts: 490
Joined: Fri Sep 24, 2010 4:34 am

Tutorial: How to add a lyrics source

Post by tamalet »

With help of anonbeat, I've added another source:

Name: lyrics007.com
Type: Download
Source: http://www.lyrics007.com/{a}+Lyrics/{t}+Lyrics.html
Extract: </script><br><br><br> -> <br><script
Exclude: <script type="text/javascript">
Not Found: Sorry, this song or the artist is deleted.

It seems that the site works quite well so anonbeat has added it to the sources. However, the sources are not updated automatically to not remove any change you may have done. To get the latest official version just delete your ~/.guayadeque/lyrics_sources.xml file and restart Guayadeque.
pickarooney
Posts: 69
Joined: Sun Oct 31, 2010 2:58 pm

Tutorial: How to add a lyrics source

Post by pickarooney »

Is there any way that uploading lyrics to various sites could be implemented from within guayadeque?
User avatar
anonbeat
Posts: 2048
Joined: Thu Sep 16, 2010 9:47 pm

Tutorial: How to add a lyrics source

Post by anonbeat »

pickarooney wrote:Is there any way that uploading lyrics to various sites could be implemented from within guayadeque?
With Target Command can be done
Locked