1
Plugins / Re: LyricsReloaded (Updated)
« on: January 19, 2022, 09:29:07 AM »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.