From a93579d3f74c0056503be11040dd55e645effd43 Mon Sep 17 00:00:00 2001 From: chinarulezzz Date: Sun, 26 Jun 2016 15:45:28 +0300 Subject: [PATCH 1/2] lyrics plugin: fix MusixMatch to meet the last API changes --- plugins/lyrics.pm | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/lyrics.pm b/plugins/lyrics.pm index 32222a9f..b14a4a85 100644 --- a/plugins/lyrics.pm +++ b/plugins/lyrics.pm @@ -76,15 +76,28 @@ my %Sites= # id => [name,url,?post?,function] if the function return 1 => lyrics return 0 if $_[0]=~m![...](?:
)*!; # truncated lyrics : "[...]" followed by italic explanation => not auto-saved return !!$1; }], - musixmatch => [musixmatch => 'https://www.musixmatch.com/lyrics/%a/%t', undef, + musixmatch => [musixmatch => sub { - if ($_[0] =~ /(.+?)<\/span>.*/$1/s; - $_[0] =~ s/[\r\n]/
/g; - } else { - $_[0] = $notfound; - } - }], + ::ReplaceFields($_[0], 'https://www.musixmatch.com/lyrics/%a/%t', sub { + require Unicode::Normalize; + import Unicode::Normalize 'NFKD'; + NFKD($_[0])=~ s/\p{NonspacingMark}//gr # Convert letters with accents, umlauts, etc to their ASCII counterparts + =~ s/ (&|\*|\-) / /gr + =~ s/(\'|\,|\.) / /gr + =~ s/\(.*?\)//gr # remove comments in parenthesis: a.e. (Extended Version), (Chillout Mix), etc + =~ s/^\s+|\s+$//gr + =~ s/\s/-/gr + }); + }, + undef, + sub { + my $text; + if($_[0] =~ /"body":"(.*?)","/){ + $text = $1 =~ s|\\n|
|gr =~ s|\\(["'])|$1|gr; + } + $_[0] = $text || $notfound; + return !!$text; + }], #lyricwikiapi => [lyricwiki => 'http://lyricwiki.org/api.php?artist=%a&song=%t&fmt=html',undef, # sub { $_[0]!~m#
\W*Not found\W*
#s }], #azlyrics => [ azlyrics => 'http://search.azlyrics.com/cgi-bin/azseek.cgi?q="%a"+"%t"'], From 6d9a5c6ad3caad3f57450c70551627e2ea763e12 Mon Sep 17 00:00:00 2001 From: Alexandr Savca Date: Sat, 11 Mar 2017 09:10:23 +0200 Subject: [PATCH 2/2] lyrics plugin: remove musixmatch NKFD translations Musixmatch now uses utf-8 api. --- plugins/lyrics.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/lyrics.pm b/plugins/lyrics.pm index b14a4a85..456a627d 100644 --- a/plugins/lyrics.pm +++ b/plugins/lyrics.pm @@ -79,14 +79,11 @@ my %Sites= # id => [name,url,?post?,function] if the function return 1 => lyrics musixmatch => [musixmatch => sub { ::ReplaceFields($_[0], 'https://www.musixmatch.com/lyrics/%a/%t', sub { - require Unicode::Normalize; - import Unicode::Normalize 'NFKD'; - NFKD($_[0])=~ s/\p{NonspacingMark}//gr # Convert letters with accents, umlauts, etc to their ASCII counterparts - =~ s/ (&|\*|\-) / /gr - =~ s/(\'|\,|\.) / /gr - =~ s/\(.*?\)//gr # remove comments in parenthesis: a.e. (Extended Version), (Chillout Mix), etc - =~ s/^\s+|\s+$//gr - =~ s/\s/-/gr + $_[0] =~ s/ (&|\*|\-) / /gr + =~ s/(\'|\,|\.) / /gr + =~ s/\(.*?\)//gr # remove comments in parenthesis: a.e. (Extended Version), (Chillout Mix), etc + =~ s/^\s+|\s+$//gr + =~ s/\s/-/gr }); }, undef,