mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-11-25 04:51:12 +08:00
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:
parent
73df7f28f4
commit
76a8742d61
|
@ -25,7 +25,11 @@ export function parseLyric(lrc) {
|
|||
const ms = Number(t.match(/\d*\]/i)[0].slice(0, 2)) / 100;
|
||||
const time = min * 60 + sec + ms;
|
||||
if (content !== '') {
|
||||
lrcObj.push({ time: time, rawTime: timeRegExpArr[0], content });
|
||||
lrcObj.push({
|
||||
time: time,
|
||||
rawTime: timeRegExpArr[0],
|
||||
content: content.trim(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,23 @@ export default {
|
|||
return false;
|
||||
} else {
|
||||
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.tlyric = [];
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user