From 9576645999ef28ffc7845d2a7d7dfd665a8a0e7e Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 16 Apr 2026 17:56:56 -0700 Subject: remove backing vocals/lyrics if set_backing is set to true in game code --- src/app/game/game.utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/app/game/game.utils.ts') 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) { -- cgit v1.2.3