浏览代码

const ignoredTags = [ 'hash', 'sign', 'qq', 'total']; // 歌词解析 需要忽略的标签

onecold 1 年之前
父节点
当前提交
d6e6fe901a
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      lib/src/main/ets/parse/LyricParser.ts

+ 7 - 0
lib/src/main/ets/parse/LyricParser.ts

@@ -28,6 +28,7 @@ export class LyricParser implements IParser {
         let album = ""
         let by = ""
         let offset = 0
+        const ignoredTags = [ 'hash', 'sign', 'qq', 'total']; // 定义需要忽略的标签
         for (let i = 0; i < src.length; i++) {
             let line = src[i]
             console.info(`content The line of file:line ${line}`);
@@ -36,6 +37,12 @@ export class LyricParser implements IParser {
                 printW("the lyric line is empty, carriage return or line feed, line index= " + i)
                 continue
             }
+            // 检查是否是需要忽略的标签
+            const shouldIgnore = ignoredTags.some(tag  => line.indexOf(tag)  > 0);
+            if (shouldIgnore) {
+                printW(`the lyric line contains ignored tag, line index= ${i}`);
+                continue;
+            }
             if (line.indexOf("ti") > 0) {
                 title = this.parseIdTag(line)
             } else if (line.indexOf("ar") > 0) {