diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-04-16 17:56:56 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-04-16 17:56:56 -0700 |
| commit | 9576645999ef28ffc7845d2a7d7dfd665a8a0e7e (patch) | |
| tree | 241fd02e90b97e82c86008aa095510e0d65253a9 /src/app/game/game.utils.ts | |
| parent | 8d40f4f62c74f020db34a6432e03075b574e33a8 (diff) | |
remove backing vocals/lyrics if set_backing is set to true in game code
Diffstat (limited to 'src/app/game/game.utils.ts')
| -rw-r--r-- | src/app/game/game.utils.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/app/game/game.utils.ts b/src/app/game/game.utils.ts index 4c99c55..9164dc9 100644 --- a/src/app/game/game.utils.ts +++ b/src/app/game/game.utils.ts @@ -3,9 +3,13 @@ export interface GameLine { content: string; } -export function parseLrcLines(lrcText: string): GameLine[] { +export function parseLrcLines( + lrcText: string, + options?: { skipBacking?: boolean } +): GameLine[] { const result: GameLine[] = []; const lineRegex = /\[(\d{2,3}):(\d{2})\.(\d{2,3})\]/g; + const { skipBacking = false } = options ?? {}; for (const rawLine of lrcText.split("\n")) { const timestamps: number[] = []; @@ -27,10 +31,10 @@ export function parseLrcLines(lrcText: string): GameLine[] { if (timestamps.length === 0) continue; - const content = rawLine - .slice(lastIndex) - .replace(/\([^)]*\)/g, "") - .trim(); + const content = (skipBacking + ? rawLine.slice(lastIndex).replace(/\([^)]*\)/g, "") + : rawLine.slice(lastIndex) + ).trim(); if (!content) continue; for (const ms of timestamps) { |
