Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lyrics plugin: fix MusixMatch to meet the last API changes #133

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions plugins/lyrics.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,25 @@ my %Sites= # id => [name,url,?post?,function] if the function return 1 => lyrics
return 0 if $_[0]=~m!&#91;&#46;&#46;&#46;&#93;(?:<br ?/>)*<i>!; # 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 id="lyrics-html"/) {
$_[0] =~ s/.*<span id="lyrics-html".+?>(.+?)<\/span>.*/$1/s;
$_[0] =~ s/[\r\n]/<br>/g;
} else {
$_[0] = $notfound;
}
}],
::ReplaceFields($_[0], 'https://www.musixmatch.com/lyrics/%a/%t', sub {
$_[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,
sub {
my $text;
if($_[0] =~ /"body":"(.*?)","/){
$text = $1 =~ s|\\n|<br>|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#<pre>\W*Not found\W*</pre>#s }],
#azlyrics => [ azlyrics => 'http://search.azlyrics.com/cgi-bin/azseek.cgi?q="%a"+"%t"'],
Expand Down