Could you make a tut about customizing the provider files? There are many sites that I want to try.
I'll try to come up with a more detailed explanation the coming weekend.
Let's have a look at this website:
https://www.lyrics.com/We'll be using the song
How Do I Live by artist
Trisha Yearwood as an example.
The lyrics for it are hosted here:
https://www.lyrics.com/lyric/20949555/Trisha+Yearwood/How+Do+I+Livename: Lyrics
loader: search
name >> this is the provider name that will show up in Preferences / Tags (2) / Lyrics.
loader >> I've already explained in post #165 the different types of loaders, and the reason why we'll be working with the search loader for this website.
variables:
artist:
type: artist
filters:
- lowercase
- [replace, ' ', '%2B']
title:
type: title
filters: artist
The
variables section is optional. This is where we can format the tags (artist, title and album) received from MusicBee. If for instance, the website you are dealing with throws a 404 error whenever the url contains a period (.) , then you would have to remove/replace every occurrence of that character in your tags before the plugin can conduct the search - otherwise you would never get results for such songs.
For this provider, I have converted the artist and title tags into lower case (probably not necessary but it's just a habit of mine).
I have also replaced whitespaces with a %2B. This is absolutely necessary for this provider as you'll see in a moment.
config:
identity url: "https://www.google.com/search?q=lyrics.com+{title}+{artist}"
identity pattern: ['(?<identity>https://www.lyrics.com/lyric/.*?/{artist}.*?)["&]', 's']
identity url >> the plugin will first conduct this search:
https://www.google.com/search?q=lyrics.com+how%2Bdo%2Bi%2Blive+trisha%2ByearwoodThen on that webpage, it will look for the first url that matches the defined identity pattern.
In order to know the kind of pattern you have to construct, you'll have to inspect the source code of the webpage.
Don't know about other web browsers but in Chrome, I do that by pressing <Ctrl>+<U> and the resultant html page looks like this for the above google search:

At this point, I usually just copy all of that into Notepad++ as it supports regex searching which will be important in my testing.
So in all that clutter, the identity pattern will go and grab only this part:
Also note how the search would have failed had I not converted
trisha yearwood into
trisha%2Byearwood.

lyrics url: ""
lyrics pattern: ['<pre id="lyric-body-text".*?>(?<lyrics>.*?)</pre>', 's']
So after the plugin has captured the content (identity) that I'm interested in, it'll go on to combine that with the lyrics url:
lyrics url >> I've left this part blank because we've already captured the entire url needed to take us to the lyrics webpage.
So the plugin actually interprets this lyrics url as
<blank> + captured content, which equates to:
<blank> +
https://www.lyrics.com/lyric/20949555/Trisha%2BYearwood/How%2BDo%2BI%2BLiveIf we had only captured this part:
20949555/Trisha%2BYearwood/How%2BDo%2BI%2BLiveThen the yml would need to have
<< lyrics url: "
https://www.lyrics.com/lyric/"
>> so that the next conducted search is:
https://www.lyrics.com/lyric/ +
20949555/Trisha%2BYearwood/How%2BDo%2BI%2BLiveSo now that we've finally gotten to our lyrics page, all that's left is to create another pattern which will only capture the lyric portion.
That's what the
lyrics pattern is for. Same as the identity thingy, you'll have to inspect the page source and then formulate the necessary pattern.
post-filters:
- strip_html
- utf8_encode
- entity_decode
- clean_spaces
- trim
The
post-filters section is also optional.
When included, it serves the purpose of polishing and refining the captured lyrics right before the plugin can send them back to MusicBee.