Author Topic: LyricsReloaded (Updated)  (Read 113306 times)

wavedash

  • Newbie
  • *
  • Posts: 4
Can anyone help me with a Regex problem? I'm trying to make a duplicate Musixmatch yaml that'll try to get lyrics for artists with swapped name order.

Example: I have a song titled "Kieru Daydream" by "Kawano Marina". But the Musixmatch URL is https://www.musixmatch.com/lyrics/Marina-Kawano/Kieru-Daydream. Predictably, here's what happens with the updated Musixmatch yaml from a few pages back:

Code
18/01/2022 09:27:38 [INFO] Musixmatch-Update tries to load the lyrics...
18/01/2022 09:27:38 [DEBUG] The constructed URL: http://www.musixmatch.com/lyrics/kawano-marina/kieru-daydream
18/01/2022 09:27:38 [INFO] No lyrics found.
18/01/2022 09:27:38 [DEBUG] no lyrics found from Musixmatch-Update

I'm trying stuff like this, but it seems like it isn't matching:

Code
[regex, '(\w+) (\w+)', '\2 \1']
or
[regex, '([a-z]+) ([a-z]+)', '\2 \1']

Code
18/01/2022 09:37:59 [INFO] Musixmatch-Name-Order tries to load the lyrics...
18/01/2022 09:37:59 [DEBUG] The constructed URL: http://www.musixmatch.com/lyrics/kawano-marina/kieru-daydream
18/01/2022 09:37:59 [INFO] No lyrics found.
18/01/2022 09:37:59 [DEBUG] no lyrics found from Musixmatch-Name-Order

avitar

  • Newbie
  • *
  • Posts: 10
Quote
[regex, '(\w+) (\w+)', '\2 \1']

You were on the right track. The problem was mostly the backreference. What you need is this:

Code
    - [regex, '(\w+)(\s)(\w+)', $3$2$1]

Unlike normal find/replace syntax, you are passing these variables back to plugin - written in C#. The plugin won't recognize the \1 syntax and throws an error.

You probably already know, but you would place this line above the following line in the artist variable area:

Code
     - [strip_nonascii, -]

Another problem you may face is that many of these configuration files use the filters from the "artist" field  for the title and album fields. It reduces typing. You'll see something like this.


Code
   title:
        type: title
        filters: artist


Obviously if yours does that then you would have to modify the title filter. Otherwise your title would swap as well.

Another caveat to remember is that if your artist name is more than two names, then the above solution will not work. You would just be swapping the first two names around.  However I can't imagine that Musixmatch would do this swapping thing for an artist with more than two names - ie David Allen Coe vs Coe Allen David or some such nonsense. So you should be good.

Anyway, I have included the yml code with everything modified and in the right place. I tested it prior to posting and it works fine (or rather I got a bunch of lyrics; in Japanese I think.) The bottom line is that I received lyrics from  the site.


The following yml file code is a special case. It will not work for normal requests to Musixmatch.

Code
name: Musixmatch Swap Artist Order

variables:
    artist:
        type: artist
        filters:
        - strip_diacritics
        - lowercase
        # -----------Library Unique------------ #
        - [replace, "!!!", "chk-chik-chick"]    
        - [regex, '(?<=\W|\s)+(featuring.+|feat[\W\s]+|ft[\W\s]+|(f[\W\s])).+', ""]                          
        #--------------URL Unique-------------- #
        # [regex, ' & ', " and "]              
        # ------------------------------------- #
        - [regex, '[^a-z0-9\s]{1,}', ""]      
        - [regex, '[\W]{2,}', " "]              
        - [regex, '(\W+(?=$))|(^\W+)', ""]
        - [regex, '(\w+)(\s)(\w+)', $3$2$1]          
        - [strip_nonascii, -]
    
    title:
        type: title
        filters:
        - strip_diacritics
        - lowercase
        # -----------Library Unique------------ #
                        
        #--------------URL Unique-------------- #
            
        # ------------------------------------- #
        - [regex, '[^a-z0-9\s]{1,}', ""]      
        - [regex, '[\W]{2,}', " "]              
        - [regex, '(\W+(?=$))|(^\W+)', ""]          
        - [strip_nonascii, -]

    album:
        type: album
        filters:
        - strip_diacritics
        - lowercase
        # -----------Library Unique------------ #
                        
        #--------------URL Unique-------------- #
            
        # ------------------------------------- #
        - [regex, '[^a-z0-9\s]{1,}', ""]      
        - [regex, '[\W]{2,}', " "]              
        - [regex, '(\W+(?=$))|(^\W+)', ""]          
        - [strip_nonascii, -]

headers:
    User-Agent: 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:77.0) Gecko/20100101 Firefox/77.0'  

config:
    url: "http://www.musixmatch.com/lyrics/{artist}/{title}"
    pattern: ['<p class="mxm-lyrics__content.*?">(?<lyrics>.*?)<div [^>]*"lyrics-report".*?>', s]

post-filters:
        #------------Website Unique------------- #
        - [replace, "</span></p><div>", "\n"]
        - [regex, "<script.*?</script>", "", 's']
        #--------------------------------------- #
        - br2nl        
        - strip_html                            
        - utf8_encode                          
        - entity_decode                        
        - clean_spaces                          
        - [regex, '\[.+\]', ""]                  
        - [regex, '\n{2,}',"\n\n", 's']          
        - trim

Let me know if you need any more assistance.
Last Edit: January 19, 2022, 09:12:13 PM by avitar

LazR

  • Newbie
  • *
  • Posts: 17
Small change for Genius. With the old '(2021-11-30)' version it just started adding -- 'xxxx Lyrics' to the top so changed the div class where lyrics should start.

If anyone knows how to regex fix there not being a space where ads would appear that would be great.

Code
name: Genius (2022)

variables:
    artist:
        type: artist
        filters:
        - strip_diacritics
        - lowercase
        - [replace, "!!!", "chk-chik-chick"]
        - [regex, '(?<=\W|\s)+(feat.+|ft[\W\s]+|(f\.\s)).+', ""]
        - [regex, '\.+|,+|(\W+(?=$))|(^\W+)', ""]
        - [regex, "'", ""]
        - [regex, '(?<=[a-z0-9%])[^\sa-z0-9%]+(?=[a-z0-9%]+)', "-"]
        - [regex, '((?<=\s)([^a-z0-9\s-])+(\s|\W)+)|((?<=\w)([^a-z0-9-])+(\s|\W)+)', " "]
        - [strip_nonascii, -]
    title:
        type: title
        filters: artist

config:
    url: "https://genius.com/{artist}-{title}-lyrics"
    pattern: ['<div data-lyrics-container="true" class="Lyrics__Container-sc-1ynbvzw-6 jYfhrf">(?<lyrics>.*)<div class="Lyrics__Footer-sc-', 's']

post-filters:
- br2nl
- strip_html
- utf8_encode
- entity_decode
- clean_spaces
- [regex, '\n{2,}',"\n\n", 's']
- trim

sveakul

  • Hero Member
  • *****
  • Posts: 1886
Small change for Genius. With the old '(2021-11-30)' version it just started adding -- 'xxxx Lyrics' to the top so changed the div class where lyrics should start.
Thanks LazR for the working fix!

For those who prefer to keep the "section" type headers out of the lyrics ([refrain], etc) add the code line below above the existing regex expression in the post-filters section:

Code
- [regex, '\[.{1,75}\]', ""]
Remember to re-add Genius after the substitution in the provider hierarchy if keeping the changed "Name" line in LazR's code.  Like him I prefer to keep a date designation there.  Here is the complete code that includes the added regex line mentioned above:

Code
name: Genius (2022)

variables:
    artist:
        type: artist
        filters:
        - strip_diacritics
        - lowercase
        - [replace, "!!!", "chk-chik-chick"]
        - [regex, '(?<=\W|\s)+(feat.+|ft[\W\s]+|(f\.\s)).+', ""]
        - [regex, '\.+|,+|(\W+(?=$))|(^\W+)', ""]
        - [regex, "'", ""]
        - [regex, '(?<=[a-z0-9%])[^\sa-z0-9%]+(?=[a-z0-9%]+)', "-"]
        - [regex, '((?<=\s)([^a-z0-9\s-])+(\s|\W)+)|((?<=\w)([^a-z0-9-])+(\s|\W)+)', " "]
        - [strip_nonascii, -]
    title:
        type: title
        filters: artist

config:
    url: "https://genius.com/{artist}-{title}-lyrics"
    pattern: ['<div data-lyrics-container="true" class="Lyrics__Container-sc-1ynbvzw-6 jYfhrf">(?<lyrics>.*)<div class="Lyrics__Footer-sc-', 's']

post-filters:
- br2nl
- strip_html
- utf8_encode
- entity_decode
- clean_spaces
- [regex, '\[.{1,75}\]', ""]
- [regex, '\n{2,}',"\n\n", 's']
- trim

phred

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7592
Thanks to both LazR and sveakul for this update.
Download the latest MusicBee v3.4 patch from here.
Download the latest MusicBee v3.5 beta patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
Check out the MusicBee Wiki.
How to post screenshots is here

DareNova

  • Newbie
  • *
  • Posts: 1
I noticed when 2 artists work in collaboration, they'd sometimes get a separate page on genius, kinda like this: https://genius.com/artists/Oliver-tree-and-little-big. But the provider made by both LazR and sveakul wouldn't account for this, so I tried fixing this. This seems to work after putting it under the replace already in there
Code
- [replace, "&", "and"]
I don't know if this messes anything else up, but like I said, it seems to work pretty well for me

Another thing I tried doing was trying to get it to recognize "w/ ..." and "+ ..." similar to things like "feat." and "ft."
A good example would be this song: Twikipedia - titles
In my library it is titled "titles 웃 w/ funeral" to keep it similar to it's soundcloud title, but this causes the search to include the "w/" part
Here is the log created by it:
Code
28/01/2022 08:16:52 [DEBUG] Lyrics request: twikipedia - titles 웃 w/ funeral - titles 웃 - Genius
28/01/2022 08:16:52 [INFO] Genius (2022) tries to load the lyrics...
28/01/2022 08:16:52 [DEBUG] The constructed URL: https://genius.com/twikipedia-titles-w-funeral-lyrics
A similar thing happens with titles including "+" as the feat bit, like "medusa +pichu (souls1 & lewisgoing)"

sveakul

  • Hero Member
  • *****
  • Posts: 1886
I noticed when 2 artists work in collaboration, they'd sometimes get a separate page on genius, kinda like this: https://genius.com/artists/Oliver-tree-and-little-big. But the provider made by both LazR and sveakul wouldn't account for this, so I tried fixing this. This seems to work after putting it under the replace already in there
Code
- [replace, "&", "and"]
I don't know if this messes anything else up, but like I said, it seems to work pretty well for me
Thanks DareNova for this!  I notice that another user "beat you to it", ShotgunStev3 (https://getmusicbee.com/forum/index.php?topic=25406.msg189875#msg189875), but it didn't show up in complete yml posts so far.  Has anyone else been using this as described, and have you noitced any unintended results?  BTW you mentioned me in your "made by" statement, actually I haven't made any personal coding contributions other than re-arranging some lines already made by others.  The honors go to frankz, LaZr, Redearth, crisp, hiccup, and probably others I've missed.

Nayan Nepal

  • Newbie
  • *
  • Posts: 9
Can anyone help me? Whenever I click on search next provider, I only get results from 2 sites : chartlyrics and songlyrics even though I have checked every other boxes. What is wrong?

frankz

  • Hero Member
  • *****
  • Posts: 3150
The plug-in is seen as one provider by MusicBee no matter how many individual providers you search within the plug-in.  So whichever is the first site to return lyrics within the plug-in, it will always be the one offered up by MusicBee even if other sites from the plug-in also have lyrics.
A smile is happiness you'll find right under your nose.

Nayan Nepal

  • Newbie
  • *
  • Posts: 9
The plug-in is seen as one provider by MusicBee no matter how many individual providers you search within the plug-in.  So whichever is the first site to return lyrics within the plug-in, it will always be the one offered up by MusicBee even if other sites from the plug-in also have lyrics.

So if I disable songlyrics and chartlyrics and only check Genius or any other site that has the lyrics, it should work as usual? Because I think I've encountered a problem with that too as no results show up when both of the aforementioned sites are disabled.

frankz

  • Hero Member
  • *****
  • Posts: 3150
Each lyrics site native to MusicBee will be seen as an individual site and get cycled through by search next provider. All sites enabled through the plugin will be seen as one provider.  Song Lyrics and Genius are plugin providers. Chart Lyrics is not. 

If you have a specific problem song or songs, you can also just paste the lyrics for that song or those songs into MusicBee. You are not bound to let MusicBee automatically discover them.
A smile is happiness you'll find right under your nose.

Nayan Nepal

  • Newbie
  • *
  • Posts: 9
Each lyrics site native to MusicBee will be seen as an individual site and get cycled through by search next provider. All sites enabled through the plugin will be seen as one provider.  Song Lyrics and Genius are plugin providers. Chart Lyrics is not. 

If you have a specific problem song or songs, you can also just paste the lyrics for that song or those songs into MusicBee. You are not bound to let MusicBee automatically discover them.
I could do it manually, but then what would be the point of installing a plugin in the first place? Thanks for the info anyway.

frankz

  • Hero Member
  • *****
  • Posts: 3150
I could do it manually, but then what would be the point of installing a plugin in the first place?
Because it works pretty well in most situations. 
A smile is happiness you'll find right under your nose.

Nayan Nepal

  • Newbie
  • *
  • Posts: 9
Well, it works..It's just that I wanted to cycle through lyrics for a song from different sites from just the lyrics window without doing any copy-paste work. I guess chartlyrics and songlyrics will have to do for now. :)

frankz

  • Hero Member
  • *****
  • Posts: 3150
Well, it works..It's just that I wanted to cycle through lyrics for a song from different sites from just the lyrics window without doing any copy-paste work. I guess chartlyrics and songlyrics will have to do for now. :)
It's hard when the things we download from the internet for free aren't perfect, but it's a burden we must all bear.  ;D

Just wait until you start trying to look at artist pictures!
A smile is happiness you'll find right under your nose.