feat: better lyrics filter (#1210)

* feat: better filter lyrics

* change

* replace filter text with RegExp

* more change

* add try catch

* better author filter
This commit is contained in:
memorydream 2022-01-11 19:06:47 +08:00 committed by GitHub
parent 73df7f28f4
commit 76a8742d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -25,7 +25,11 @@ export function parseLyric(lrc) {
const ms = Number(t.match(/\d*\]/i)[0].slice(0, 2)) / 100; const ms = Number(t.match(/\d*\]/i)[0].slice(0, 2)) / 100;
const time = min * 60 + sec + ms; const time = min * 60 + sec + ms;
if (content !== '') { if (content !== '') {
lrcObj.push({ time: time, rawTime: timeRegExpArr[0], content }); lrcObj.push({
time: time,
rawTime: timeRegExpArr[0],
content: content.trim(),
});
} }
} }
} }

View File

@ -327,7 +327,23 @@ export default {
return false; return false;
} else { } else {
let { lyric, tlyric } = lyricParser(data); let { lyric, tlyric } = lyricParser(data);
if (lyric.length === 1 && lyric[0].content === '纯音乐,请欣赏') { lyric = lyric.filter(
l => !/^作(词|曲)\s*(:|)\s*无$/.exec(l.content)
);
let includeAM =
lyric.length <= 10 &&
lyric.map(l => l.content).includes('纯音乐,请欣赏');
if (includeAM) {
let reg = /^作(词|曲)\s*(:|)\s*/;
let author = this.currentTrack?.ar[0]?.name;
lyric = lyric.filter(l => {
let regExpArr = l.content.match(reg);
return (
!regExpArr || l.content.replace(regExpArr[0], '') !== author
);
});
}
if (lyric.length === 1 && includeAM) {
this.lyric = []; this.lyric = [];
this.tlyric = []; this.tlyric = [];
return false; return false;