From 2341d13721c864561d6e86fd637a99c823ea3414 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Wed, 24 Jul 2024 20:30:24 -0500 Subject: [PATCH 1/9] feat: parsec based lyric parser Signed-off-by: eternal-flame-AD --- bun.lockb | Bin 158121 -> 158500 bytes package.json | 1 + src/lib/lyrics/parser.ts | 217 ++++++++++++++++++++++++++++++--- src/test/lrcParser.test.ts | 61 +++++++-- src/test/resources/test-02.lrc | 9 ++ 5 files changed, 260 insertions(+), 28 deletions(-) create mode 100644 src/test/resources/test-02.lrc diff --git a/bun.lockb b/bun.lockb index d65fe0800b636daceea3d4cd07b96c46400b7d66..570f2554d2852d9d48174ec86d591461388d9a03 100755 GIT binary patch delta 26947 zcmeIbcX(7)*Y`hrU?2w!5L!rq5SjueKqyHF$$%7vp{f{AQ38n&AhZAyFeX^xMpWG5 z1~G_;N)ZG_ApxX_N)ZGbO+XasC|J;-$opC6oB{6V_IcjxdavjD{qyt4_pH6vUc0Qd z*Df=2a$NkmweTzJ+4#oIK1s;TxG(Xck9Mwq{YKrcYN;jc&hE z-s76o z`Fatq53+}3k9=U1X9RNEC_IQ<#;HxDLkpoYu1%p8Jq4b^u~`{|$Hism1_yFF11MuS zI%C|>EPQq!70DR3fl5X5i3Z_=0noa(BOftp{AkgC%jHMMjmXZ)9_MLQ$MJh_x1Od@ z8HaJ%BlB_xjL!269-5I&InSsVCqo*ZkTJrOnUyssTBM zUjcczOEU(K8atBuD%H}b%hV}&uYt!ymkM8mN+9REd?pm%6n25q#lm_}{uO$;QFGz3 z`i^`Plz)XUbE^j}gwm7343~C5Zm#FJo>?}$s*heu zIQ~i035~p2my~VO;z*n`jGsZp%O61{O2rv*!?W^AT>dSncyFPO^@Yd2*UWLrwB}B! zp!SPsiA!ec{=ORv!dp5qPA9T*2YWna;U(l|Bsg8j%g7mlzdXOdOUN9D$_Vds>Da8? zQ6nZ~dDgXdEPop+wJ(H<-q4KPQ4iwri*1}<^mFq^XFrffwFRC|2xQW1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y+T5FJI{`agFqiVwusd?|H6hDct{>Y(b}nc6P_4`rQqo^cUP`i$5UQj3yQFhpK0S9% z^$$|?n?F&Yk2y@b0cO1;c-ehhb=j$hPj&xf2WzW!)SyQ9z1Cs7W*A2&uUhW7ftcsb ziDYf;yl*=%{i*X~vwEI zdj3vWRA5_~YDFnZmKu7s%{qj5&z} zJa{%2AvLc3M%~Y5e)1a?{pVd_?fR|F$fKk`(c4Tos`Aux=7ytcF3+=dKgQVj>mKZG zz9tE>`q{h6^5`C~{xskYxX`t(;P9=9D9P#5nr|d1FtqO3pOfpQOZibHYigX<^Ph$$H_wn!Mhd zNn6iM?mv-itcTLzzUD2`{n>X>=iq+iakJqmocGtG+jd?@@7kf}r>E5Y-t9xp-%hD+ z9BMm%OK(1HUi_9C+?SHay*S{BZS!BD3DfyKQjSkcMwnH;W2OcQaZc`XE*|k6ZTatIeagKQDeFk4xk<`$Uva*!;*M|j?fc_9$Ab+T@pzMYl``D# zK~Z$4`xI2>?9WO(HKn6jQVkkuj}&LG33uO!zUzFWw??lzcFB9^i+>+;>S^5ljJX9N zn+E$~`9clqPcuW$u*aI__h(eJnR7;!4nLJ;kE`r4>BHoIIC62;$-zyh&8k?E2T2#5 zVYRjstC41@vuZHU297^#7s>A%9n}lw?@+bKtar{Ww{j2*#CJL7>~pGN8TTFPPtMr( zXwj`z=6lI;^qfkJcVBy6sOg&3%^sh1Ok81qO{p=?{RR;ojkMa1xC7kV35r_@gmgzLUMmd&nK+=!o0%W{Ne)V=XT zoN`Ik=h4IsmsFJZWCQc?B~@AEZ^-spd|N0c!>ap)*Hf2Q37ZI)oqJM+?!|AHZFDRj zUJ|~eN#BS4W14>5 str.trim() !== ''); -} - -export function ExtractIDTags(lines: string[]) { - let result: IDTag = {}; - const IDTagRegex = /^\[(\w*): (.*?)]$/; - let lastMatch = 0; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; - const matchResult = line.trim().match(IDTagRegex); - if (matchResult && matchResult.length == 3) { - const tagName = matchResult[1]; - const tagValue = matchResult[2]; - result[tagName] = tagValue; - } +function convertTimeToMs({ + mins, + secs, + decimals +}: { + mins?: number | string; + secs?: number | string; + decimals?: string; +}) { + let result = 0; + if (mins) { + result += Number(mins) * 60 * 1000; + } + if (secs) { + result += Number(secs) * 1000; + } + if (decimals) { + const denom = Math.pow(10, decimals.length); + result += Number(decimals) / (denom / 1000); } return result; -} \ No newline at end of file +} + +const digit = Array.from({ length: 10 }, (_, i) => apply(str(i.toString()), (_) => i)).reduce( + (acc, cur) => alt_sc(cur, acc), + fail('no alternatives') +); +const numStr = apply(rep_sc(digit), (r) => r.join('')); +const num = apply(numStr, (r) => parseInt(r)); +const alpha = alt_sc( + Array.from({ length: 26 }, (_, i) => + apply(str(String.fromCharCode('a'.charCodeAt(0) + i)), (_) => String.fromCharCode('a'.charCodeAt(0) + i)) + ).reduce((acc, cur) => alt_sc(cur, acc), fail('no alternatives')), + Array.from({ length: 26 }, (_, i) => + apply(str(String.fromCharCode('A'.charCodeAt(0) + i)), (_) => String.fromCharCode('A'.charCodeAt(0) + i)) + ).reduce((acc, cur) => alt_sc(cur, acc), fail('no alternatives')) +); + +const alphaStr = apply(rep(alpha), (r) => r.join('')); +const spaces = rep_sc(str(' ')); + +const unicodeStr = rep_sc(tok('char')); + +function trimmed(p: Parser[]>): Parser[]> { + return apply(p, (r) => { + while (r.length > 0 && r[0].text.trim() === '') { + r.shift(); + } + while (r.length > 0 && r[r.length - 1].text.trim() === '') { + r.pop(); + } + return r; + }); +} + +function anythingTyped(types: string[]) { + return types.map((t) => tok(t)).reduce((acc, cur) => alt_sc(cur, acc), fail('no alternatives')); +} + +function lrcTimestamp(delim: [Parser>, Parser>]) { + const innerTS = alt_sc( + apply(seq(num, str(':'), num, str('.'), numStr), (r) => + convertTimeToMs({ mins: r[0], secs: r[2], decimals: r[4] }) + ), + apply(seq(num, str('.'), numStr), (r) => convertTimeToMs({ secs: r[0], decimals: r[2] })), + apply(seq(num, str(':'), num), (r) => convertTimeToMs({ mins: r[0], secs: r[2] })), + apply(num, (r) => convertTimeToMs({ secs: r })) + ); + return kmid(delim[0], innerTS, delim[1]); +} + +const squareTS = lrcTimestamp([tok('['), tok(']')]); +const angleTS = lrcTimestamp([tok('<'), tok('>')]); + +const lrcTag = apply( + seq( + tok('['), + alphaStr, + str(':'), + tokenParserToText(trimmed(rep(anythingTyped(['char', '[', ']', '<', '>'])))), + tok(']') + ), + (r) => ({ + [r[1]]: r[3] + }) +); + +function tokenParserToText(p: Parser> | Parser[]>): Parser { + return apply(p, (r: Token | Token[]) => { + if (Array.isArray(r)) { + return joinTokens(r); + } + return r.text; + }); +} + +function joinTokens(tokens: Token[]) { + return tokens.map((t) => t.text).join(''); +} + +function lrcLine( + wordDiv = '' +): Parser { + return alt_sc( + apply(seq(squareTS, rep_sc(seq(opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']'])))))), (r) => { + const start = r[0]; + + const text = r[1] + .map((s) => joinTokens(s[1])) + .filter((s) => s.trim().length > 0) + .join(wordDiv); + + const words = r[1] + .filter((s) => joinTokens(s[1]).trim().length > 0) + .map((s) => { + const wordBegin = s[0]; + const word = s[1]; + let ret: Partial = { start: wordBegin }; + if (word[0]) { + ret.beginIndex = word[0].pos.columnBegin - 1; + } + if (word[word.length - 1]) { + ret.endIndex = word[word.length - 1].pos.columnEnd; + } + return ret as ScriptWordsItem; // TODO: Complete this + }); + return ['script_item', { start, text, words } as any as ScriptItem]; // TODO: Complete this + }), + apply(lrcTag, (r) => ['lrc_tag', r as IDTag]), + apply(seq(spaces, str('#'), rep_sc(unicodeStr)), (cmt) => ['comment', cmt[2].join('')] as const) + ); +} + +export function dumpToken(t: Token | undefined): string { + if (t === undefined) { + return ''; + } + return '`' + t.text + '` -> ' + dumpToken(t.next); +} + +export function parseLRC( + input: string, + { wordDiv, strict }: { wordDiv?: string; strict?: boolean } = { wordDiv: ' ' } +): LrcJsonData { + const tokenizer = buildLexer([ + [true, /^\[/gu, '['], + [true, /^\]/gu, ']'], + [true, /^/gu, '>'], + [true, /^./gu, 'char'] + ]); + + const lines = input + .split('\n') + .filter((line) => line.trim().length > 0) + .map((line) => tokenizer.parse(line)); + + return lines + .map((line) => { + const res = expectEOF(lrcLine(wordDiv).parse(line)); + if (!res.successful) { + if (strict) { + throw new Error('Failed to parse full line: ' + dumpToken(line)); + } else { + console.error('Failed to parse full line: ' + dumpToken(line)); + } + return null; + } + return res.candidates[0].result; + }) + .filter((r) => r !== null) + .reduce((acc, cur) => { + switch (cur[0]) { + case 'lrc_tag': + Object.assign(acc, cur[1]); + return acc; + case 'script_item': + acc.scripts = acc.scripts || []; + acc.scripts.push(cur[1]); + return acc; + default: + return acc; + } + }, {} as LrcJsonData); +} diff --git a/src/test/lrcParser.test.ts b/src/test/lrcParser.test.ts index db31437..6310f05 100644 --- a/src/test/lrcParser.test.ts +++ b/src/test/lrcParser.test.ts @@ -1,19 +1,58 @@ import { describe, expect, it } from 'vitest'; import fs from 'fs'; -import { ExtractIDTags, splitLine } from '$lib/lyrics/parser'; +import { parseLRC } from '$lib/lyrics/parser'; describe('LRC parser test', () => { const test01Buffer = fs.readFileSync('./src/test/resources/test-01.lrc'); const test01Text = test01Buffer.toString('utf-8'); - it('Line Split', () => { - const lyrics = test01Text; - const lines = splitLine(lyrics); - expect(lines[26]).toBe('[01:52.991]'); - }); - it('IDTag Extract', () => { - const lyrics = test01Text; - const lines = splitLine(lyrics); - const idTags = ExtractIDTags(lines); - expect(idTags['ar']).toBe('洛天依'); + const test02Buffer = fs.readFileSync('./src/test/resources/test-02.lrc'); + const test02Text = test02Buffer.toString('utf-8'); + it('Parses test-01.lrc', () => { + const result = parseLRC(test01Text, { wordDiv: '', strict: true }); + + expect(result.ar).toBe("洛天依"); + expect(result.ti).toBe("中华少女·终"); + expect(result.al).toBe("中华少女"); + expect(result["tool"]).toBe("歌词滚动姬 https://lrc-maker.github.io"); + expect(result.scripts!![1].text).toBe("因果与恩怨牵杂等谁来诊断"); + expect(result.scripts!![1].start).toBe(49000 + 588); + }) + it('Parses test-02.lrc', () => { + const result = parseLRC(test02Text, { wordDiv: ' ', strict: true }); + + expect(result.ti).toBe("Somebody to Love"); + expect(result.ar).toBe("Jefferson Airplane"); + expect(result.scripts!![0].text).toBe("When the truth is found to be lies"); + expect(result.scripts!![0].start).toBe(0); + expect(result.scripts!![0].words!![1].beginIndex).toBe("[00:00.00] <00:00.04> When <00:00.16> the".indexOf("the")); + expect(result.scripts!![0].words!![1].start).toBe(160); }); + it('Rejects some invalid LRCs', () => { + const cases = [ + "[<00:00.00>] <00:00.04> When <00:00.16> the", + "[00:00.00] <00:00.04> <00:00.16> the", + "[00:00.00> <00:00.04> When <00:00.16> the", + "<00:00.00> <00:00.04> When <00:00.16> the", + "<1:00:00.00> <00:00.04> When <00:00.16> the", + ] + for (const c of cases) { + expect(() => parseLRC(c, { strict: true })).toThrow(); + } + }) + it('Accepts some weird but parsable LRCs', () => { + const cases = [ + "[ti: []]", + "[ar: [<]]", + "[ar: ]", + "[ar: a b c]", + "[00:00.00] <00:00.04> When the <00:00.16> the", + "[00:00.00] [00:00.04] When [00:00.16] the", + "[00:00.0000000] <00:00.04> When <00:00.16> the", + "[00:00.00] <00:00.04> [When] <00:00.16> the", + ]; + + for (const c of cases) { + expect(() => parseLRC(c, { strict: false })).not.toThrow(); + } + }) }); \ No newline at end of file diff --git a/src/test/resources/test-02.lrc b/src/test/resources/test-02.lrc new file mode 100644 index 0000000..5f67268 --- /dev/null +++ b/src/test/resources/test-02.lrc @@ -0,0 +1,9 @@ +[ti: Somebody to Love] +[ar: Jefferson Airplane] +[al: Surrealistic Pillow] +[lr: Lyricists of that song] +[length: 2:58] + +[00:00.00] <00:00.04> When <00:00.16> the <00:00.82> truth <00:01.29> is <00:01.63> found <00:03.09> to <00:03.37> be <00:05.92> lies +[00:06.47] <00:07.67> And <00:07.94> all <00:08.36> the <00:08.63> joy <00:10.28> within <00:10.53> you <00:13.09> dies +[00:13.34] <00:14.32> Don't <00:14.73> you <00:15.14> want <00:15.57> somebody <00:16.09> to <00:16.46> love \ No newline at end of file -- 2.45.2 From bf7f2f508bc5b71a82829af226f9ebfabf79055a Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Wed, 24 Jul 2024 20:59:40 -0500 Subject: [PATCH 2/9] fixup! feat: parsec based lyric parser --- src/lib/lyrics/parser.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index a8b9910..21abf74 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -86,7 +86,7 @@ const alpha = alt_sc( const alphaStr = apply(rep(alpha), (r) => r.join('')); const spaces = rep_sc(str(' ')); -const unicodeStr = rep_sc(tok('char')); +const unicodeStr = rep(tok('char')); function trimmed(p: Parser[]>): Parser[]> { return apply(p, (r) => { @@ -132,6 +132,10 @@ const lrcTag = apply( }) ); +function joinTokens(tokens: Token[]) { + return tokens.map((t) => t.text).join(''); +} + function tokenParserToText(p: Parser> | Parser[]>): Parser { return apply(p, (r: Token | Token[]) => { if (Array.isArray(r)) { @@ -141,13 +145,9 @@ function tokenParserToText(p: Parser> | Parser[]>) }); } -function joinTokens(tokens: Token[]) { - return tokens.map((t) => t.text).join(''); -} - function lrcLine( wordDiv = '' -): Parser { +): Parser { return alt_sc( apply(seq(squareTS, rep_sc(seq(opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']'])))))), (r) => { const start = r[0]; @@ -174,7 +174,8 @@ function lrcLine( return ['script_item', { start, text, words } as any as ScriptItem]; // TODO: Complete this }), apply(lrcTag, (r) => ['lrc_tag', r as IDTag]), - apply(seq(spaces, str('#'), rep_sc(unicodeStr)), (cmt) => ['comment', cmt[2].join('')] as const) + apply(seq(spaces, str('#'), unicodeStr), (cmt) => ['comment', cmt[2].join('')] as const), + apply(spaces, (_) => ['empty', null] as const) ); } -- 2.45.2 From bb27df5c8dea6986c99989d10a81afebd88aab51 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Thu, 25 Jul 2024 19:03:09 +0800 Subject: [PATCH 3/9] fix: prevent negative transform in lyrics update. ref: let the code in lyrics more structured add: global truncate function improve: small improvements in routes/play/[id] --- package.json | 2 +- src/lib/components/interactiveBox.svelte | 5 +- src/lib/components/lyrics.svelte | 234 ++++++++++++----------- src/lib/truncate.ts | 3 + src/routes/play/[id]/+page.svelte | 24 +-- 5 files changed, 133 insertions(+), 135 deletions(-) create mode 100644 src/lib/truncate.ts diff --git a/package.json b/package.json index 0342a7d..395bcc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aquavox", - "version": "1.12.13", + "version": "1.12.14", "private": false, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/interactiveBox.svelte b/src/lib/components/interactiveBox.svelte index 0bbf0e5..1d55162 100644 --- a/src/lib/components/interactiveBox.svelte +++ b/src/lib/components/interactiveBox.svelte @@ -3,6 +3,7 @@ import { onMount } from 'svelte'; import userAdjustingProgress from '$lib/state/userAdjustingProgress'; import progressBarSlideValue from '$lib/state/progressBarSlideValue'; + import truncate from '$lib/truncate'; export let name: string; export let singer: string = ''; @@ -49,10 +50,6 @@ progressBarSlideValue.set((e.offsetX / progressBar.getBoundingClientRect().width) * duration); } - function truncate(value: number, min: number, max: number) { - return Math.min(Math.max(value, min), max); - } - function progressBarMouseUp(offsetX: number) { adjustDisplayProgress(offsetX / progressBar.getBoundingClientRect().width); } diff --git a/src/lib/components/lyrics.svelte b/src/lib/components/lyrics.svelte index 92cd78f..59135ca 100644 --- a/src/lib/components/lyrics.svelte +++ b/src/lib/components/lyrics.svelte @@ -5,6 +5,7 @@ import type { LrcJsonData } from 'lrc-parser-ts'; import progressBarSlideValue from '$lib/state/progressBarSlideValue'; import nextUpdate from '$lib/state/nextUpdate'; + import truncate from '$lib/truncate'; // Component input properties export let lyrics: string[]; @@ -38,6 +39,22 @@ $: refs = _refs.filter(Boolean); $: getLyricIndex = createLyricsSearcher(originalLyrics); + + // handle KeyDown event + function onKeyDown(e: KeyboardEvent) { + if (e.altKey && e.shiftKey && (e.metaKey || e.key === 'OS') && e.key === 'Enter') { + debugMode = !debugMode; + localStorage.setItem('debugMode', debugMode ? 'true' : 'false'); + } + } + + // using for debug mode + function extractTranslateValue(s: string): string | null { + const regex = /translateY\((-?\d*px)\)/; + let arr = regex.exec(s); + return arr==null ? null : arr[1]; + } + // Helper function to get CSS class for a lyric based on its index and progress function getClass(lyricIndex: number, progress: number) { if (!originalLyrics.scripts) return 'previous-lyric'; @@ -117,7 +134,110 @@ }, 500); } - // Handle user adjusting progress state changes + // Handle scroll events in the lyrics container + function scrollHandler() { + scrolling = !scriptScrolling; + if (scrolling && originalLyrics.scripts) { + lastScroll = new Date().getTime(); + for (let i = 0; i < originalLyrics.scripts.length; i++) { + if (refs[i]) { + refs[i].style.filter = 'blur(0px)'; + } + } + } + setTimeout(() => { + if (new Date().getTime() - lastScroll > 5000) { + scrolling = false; + } + }, 5500); + } + + // Utility function to create a sleep/delay + function sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + + // Scroll to corresponding lyric while adjusting progress + $: { + if ($userAdjustingProgress == true) { + const currentLyric = refs[getLyricIndex(progress)]; + scrollToLyric(currentLyric); + } + } + + // Update the current lyric and apply blur effect based on the progress + // worked in real-time. + $: { + (() => { + if (!lyricsContainer || !originalLyrics.scripts) return; + + const scripts = originalLyrics.scripts; + currentPositionIndex = getLyricIndex(progress); + const cl = scripts[currentPositionIndex]; + + if (cl.start <= progress && progress <= cl.end) { + currentLyricIndex = currentPositionIndex; + nextUpdate.set(cl.end); + } else { + currentLyricIndex = -1; + nextUpdate.set(cl.start); + } + + const currentLyric = refs[currentPositionIndex]; + if ($userAdjustingProgress || scrolling || currentLyric.getBoundingClientRect().top < 0) return; + + for (let i = 0; i < scripts.length; i++) { + const offset = Math.abs(i - currentPositionIndex); + const blurRadius = Math.min(offset * 0.96, 16); + if (refs[i]) { + refs[i].style.filter = `blur(${blurRadius}px)`; + } + } + })(); + } + + // Main function that control's lyrics update during playing + // triggered by nextUpdate's update + async function lyricsUpdate(){ + if ( + currentPositionIndex < 0 || + currentPositionIndex === currentAnimationIndex || + currentPositionIndex === lastAdjustProgress || + $userAdjustingProgress === true || + scrolling + ) return; + + const currentLyric = refs[currentPositionIndex]; + const currentLyricRect = currentLyric.getBoundingClientRect(); + + if (originalLyrics.scripts && currentLyricRect.top < 0) return; + + const offsetHeight = truncate(currentLyricRect.top - currentLyricTopMargin, 0, Infinity); + + // prepare current line + currentLyric.style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, + opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; + currentLyric.style.transform = `translateY(${-offsetHeight}px)`; + + for (let i = currentPositionIndex - 1; i >= 0; i--) { + refs[i].style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, + opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; + refs[i].style.transform = `translateY(${-offsetHeight}px)`; + } + if (currentPositionIndex + 1 < refs.length) { + const nextLyric = refs[currentPositionIndex + 1]; + nextLyric.style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, + opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; + nextLyric.style.transform = `translateY(${-offsetHeight}px)`; + await moveToNextLine(offsetHeight); + } + currentAnimationIndex = currentPositionIndex; + } + + + nextUpdate.subscribe(lyricsUpdate) + + // Process while user is adjusting progress userAdjustingProgress.subscribe((adjusting) => { if (!originalLyrics) return; const scripts = originalLyrics.scripts; @@ -155,117 +275,6 @@ } }); - // Handle scroll events in the lyrics container - function scrollHandler() { - scrolling = !scriptScrolling; - if (scrolling && originalLyrics.scripts) { - lastScroll = new Date().getTime(); - for (let i = 0; i < originalLyrics.scripts.length; i++) { - if (refs[i]) { - refs[i].style.filter = 'blur(0px)'; - } - } - } - setTimeout(() => { - if (new Date().getTime() - lastScroll > 5000) { - scrolling = false; - } - }, 5500); - } - - // Utility function to create a sleep/delay - function sleep(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); - } - - // Scroll to corresponding lyric while adjusting progress - $: { - if ($userAdjustingProgress == true) { - const currentLyric = refs[getLyricIndex(progress)]; - scrollToLyric(currentLyric); - } - } - - // Update the current lyric and apply blur effect based on the progress - $: { - (() => { - if (!lyricsContainer || !originalLyrics.scripts) return; - - const scripts = originalLyrics.scripts; - currentPositionIndex = getLyricIndex(progress); - const cl = scripts[currentPositionIndex]; - - if (cl.start <= progress && progress <= cl.end) { - currentLyricIndex = currentPositionIndex; - nextUpdate.set(cl.end); - } else { - currentLyricIndex = -1; - nextUpdate.set(cl.start); - } - - const currentLyric = refs[currentPositionIndex]; - if ($userAdjustingProgress || scrolling || currentLyric.getBoundingClientRect().top < 0) return; - - for (let i = 0; i < scripts.length; i++) { - const offset = Math.abs(i - currentPositionIndex); - const blurRadius = Math.min(offset * 0.96, 16); - if (refs[i]) { - refs[i].style.filter = `blur(${blurRadius}px)`; - } - } - })(); - } - - nextUpdate.subscribe(async (nextUpdate) => { - if ( - currentPositionIndex < 0 || - currentPositionIndex === currentAnimationIndex || - currentPositionIndex === lastAdjustProgress || - $userAdjustingProgress === true || - scrolling - ) return; - - const currentLyric = refs[currentPositionIndex]; - - if (originalLyrics.scripts && currentLyric.getBoundingClientRect().top < 0) return; - - const offsetHeight = - refs[currentPositionIndex].getBoundingClientRect().top - - currentLyricTopMargin; - - // prepare current line - currentLyric.style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, - opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; - currentLyric.style.transform = `translateY(${-offsetHeight}px)`; - - for (let i = currentPositionIndex - 1; i >= 0; i--) { - refs[i].style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, - opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; - refs[i].style.transform = `translateY(${-offsetHeight}px)`; - } - if (currentPositionIndex + 1 < refs.length) { - const nextLyric = refs[currentPositionIndex + 1]; - nextLyric.style.transition = `transform .6s cubic-bezier(.28,.01,.29,.99), filter 200ms ease, - opacity 200ms ease, font-size 200ms ease, scale 250ms ease`; - nextLyric.style.transform = `translateY(${-offsetHeight}px)`; - await moveToNextLine(offsetHeight); - } - currentAnimationIndex = currentPositionIndex; - }) - - function onKeyDown(e: KeyboardEvent) { - if (e.altKey && e.shiftKey && (e.metaKey || e.key === 'OS') && e.key === 'Enter') { - debugMode = !debugMode; - localStorage.setItem('debugMode', debugMode ? 'true' : 'false'); - } - } - - function extractTranslateValue(s: string): string | null { - const regex = /translateY\((-?\d*px)\)/; - let arr = regex.exec(s); - return arr==null ? null : arr[1]; - } - @@ -290,6 +299,7 @@ class="absolute top-[6.5rem] md:top-36 xl:top-0 w-screen xl:w-[52vw] px-6 md:px-12 lg:px-[7.5rem] xl:left-[45vw] xl:px-[3vw] h-[calc(100vh-17rem)] xl:h-screen font-sans text-left no-scrollbar overflow-y-auto z-[1] pt-16 lyrics" bind:this={lyricsContainer} + on:scroll={scrollHandler} > {#each lyrics as lyric, i}

diff --git a/src/lib/truncate.ts b/src/lib/truncate.ts new file mode 100644 index 0000000..c10b4a4 --- /dev/null +++ b/src/lib/truncate.ts @@ -0,0 +1,3 @@ +export default function truncate(value: number, min: number, max: number) { + return Math.min(Math.max(value, min), max); +} \ No newline at end of file diff --git a/src/routes/play/[id]/+page.svelte b/src/routes/play/[id]/+page.svelte index 9c2c853..a68d275 100644 --- a/src/routes/play/[id]/+page.svelte +++ b/src/routes/play/[id]/+page.svelte @@ -11,6 +11,8 @@ import lrcParser, { type LrcJsonData } from 'lrc-parser-ts'; import userAdjustingProgress from '$lib/state/userAdjustingProgress'; import type { IAudioMetadata } from 'music-metadata-browser'; + import { onMount } from 'svelte'; + import progressBarRaw from '$lib/state/progressBarRaw'; const audioId = $page.params.id; let audioPlayer: HTMLAudioElement; @@ -150,20 +152,12 @@ $: { clearInterval(mainInterval); mainInterval = setInterval(() => { - if ( - audioPlayer !== null && - audioPlayer.currentTime !== undefined - ) { - if ($userAdjustingProgress === false) - currentProgress = audioPlayer.currentTime; - progressBarRaw.set(audioPlayer.currentTime); - } + if ($userAdjustingProgress === false) + currentProgress = audioPlayer.currentTime; + progressBarRaw.set(audioPlayer.currentTime); }, 50); } - import { onMount } from 'svelte'; - import progressBarRaw from '$lib/state/progressBarRaw'; - onMount(() => { audioPlayer.volume = localStorage.getItem('volume') ? Number(localStorage.getItem('volume')) : 1; }); @@ -175,13 +169,7 @@ } } - $: { - if (originalLyrics) { - hasLyrics = true; - } else { - hasLyrics = false; - } - } + $: hasLyrics = !!originalLyrics; readDB(); -- 2.45.2 From 504c8772da7fb7ad5d37a3158869042cc311e35e Mon Sep 17 00:00:00 2001 From: alikia2x Date: Fri, 26 Jul 2024 03:20:22 +0800 Subject: [PATCH 4/9] add: LICENSE --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e72bfdd --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file -- 2.45.2 From 9074f800d69171c87fc26d176f9e5f9d5cfcc390 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Fri, 26 Jul 2024 00:05:50 -0500 Subject: [PATCH 5/9] add legacy lrc parse mode Signed-off-by: eternal-flame-AD --- src/lib/lyrics/parser.ts | 10 ++++++---- src/test/lrcParser.test.ts | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index 21abf74..8803599 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -146,10 +146,12 @@ function tokenParserToText(p: Parser> | Parser[]>) } function lrcLine( - wordDiv = '' + wordDiv = ' ', legacy = false ): Parser { return alt_sc( - apply(seq(squareTS, rep_sc(seq(opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']'])))))), (r) => { + legacy ? apply(seq(squareTS, trimmed(rep_sc(anythingTyped(['char', '[', ']', '<', '>'])))), (r) => + ['script_item', { start: r[0], text: joinTokens(r[1]) } as any as ScriptItem] // TODO: Complete this + ) : apply(seq(squareTS, rep_sc(seq(opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']'])))))), (r) => { const start = r[0]; const text = r[1] @@ -188,7 +190,7 @@ export function dumpToken(t: Token | undefined): string { export function parseLRC( input: string, - { wordDiv, strict }: { wordDiv?: string; strict?: boolean } = { wordDiv: ' ' } + { wordDiv, strict, legacy }: { wordDiv?: string; strict?: boolean; legacy?: boolean } = {} ): LrcJsonData { const tokenizer = buildLexer([ [true, /^\[/gu, '['], @@ -205,7 +207,7 @@ export function parseLRC( return lines .map((line) => { - const res = expectEOF(lrcLine(wordDiv).parse(line)); + const res = expectEOF(lrcLine(wordDiv, legacy).parse(line)); if (!res.successful) { if (strict) { throw new Error('Failed to parse full line: ' + dumpToken(line)); diff --git a/src/test/lrcParser.test.ts b/src/test/lrcParser.test.ts index 6310f05..01ae0af 100644 --- a/src/test/lrcParser.test.ts +++ b/src/test/lrcParser.test.ts @@ -22,6 +22,7 @@ describe('LRC parser test', () => { expect(result.ti).toBe("Somebody to Love"); expect(result.ar).toBe("Jefferson Airplane"); + expect(result.scripts!!.length).toBe(3); expect(result.scripts!![0].text).toBe("When the truth is found to be lies"); expect(result.scripts!![0].start).toBe(0); expect(result.scripts!![0].words!![1].beginIndex).toBe("[00:00.00] <00:00.04> When <00:00.16> the".indexOf("the")); @@ -55,4 +56,14 @@ describe('LRC parser test', () => { expect(() => parseLRC(c, { strict: false })).not.toThrow(); } }) + it('Parses a legacy LRC', () => { + const result = parseLRC(test02Text, { wordDiv: ' ', strict: true, legacy: true }); + + expect(result.ti).toBe("Somebody to Love"); + expect(result.ar).toBe("Jefferson Airplane"); + expect(result.scripts!!.length).toBe(3); + expect(result.scripts!![1].text).toBe("<00:07.67> And <00:07.94> all <00:08.36> the <00:08.63> joy <00:10.28> within <00:10.53> you <00:13.09> dies"); + expect(result.scripts!![1].start).toBe(6000 + 470); + result.scripts!!.forEach((s) => expect(s.words).not.toBeDefined()); + }); }); \ No newline at end of file -- 2.45.2 From ecaa7c3e1c07aceab645dffb901885043633add5 Mon Sep 17 00:00:00 2001 From: alikia2x Date: Sat, 27 Jul 2024 15:50:40 +0800 Subject: [PATCH 6/9] temp: debug --- bun.lockb | Bin 158500 -> 158500 bytes src/lib/lyrics/parser.ts | 125 ++++++++++++++++++++++----------- src/test/lrcParser.test.ts | 7 ++ src/test/resources/test-03.lrc | 77 ++++++++++++++++++++ 4 files changed, 169 insertions(+), 40 deletions(-) create mode 100644 src/test/resources/test-03.lrc diff --git a/bun.lockb b/bun.lockb index 570f2554d2852d9d48174ec86d591461388d9a03..383e35438a2601032d8d77bc2b3996534a1547dc 100755 GIT binary patch delta 25 hcmZ2-jdRI0&W0_F{p;8n;|%nS^-Q);TgTY92LOlG3K#$Y delta 25 dcmZ2-jdRI0&W0_F{p;A77{Flrv~`SqdjNX)2*>~c diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index 8803599..fed8188 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -4,24 +4,30 @@ import { buildLexer, expectEOF, fail, + kleft, kmid, + kright, opt_sc, + type Parser, rep, rep_sc, seq, str, tok, - type Parser, type Token } from 'typescript-parsec'; -export interface ScriptItem { + +interface ParserScriptItem { start: number; text: string; - end: number; - translation?: string; words?: ScriptWordsItem[]; - singer?: number; + translation?: string; + singer?: string; +} + +export interface ScriptItem extends ParserScriptItem{ + end: number; chorus?: string; } @@ -32,12 +38,24 @@ export interface ScriptWordsItem { endIndex: number; } -export interface LrcJsonData { +export interface LrcMetaData { ar?: string; ti?: string; al?: string; - scripts?: ScriptItem[]; + au?: string; + length?: string; + offset?: string; + tool?: string; + ve?: string; +} +export interface ParsedLrc extends LrcMetaData { + scripts?: ParserScriptItem[]; + [key: string]: any; +} + +export interface LrcJsonData extends LrcMetaData { + scripts?: ScriptItem[]; [key: string]: any; } @@ -46,10 +64,10 @@ interface IDTag { } function convertTimeToMs({ - mins, - secs, - decimals -}: { + mins, + secs, + decimals + }: { mins?: number | string; secs?: number | string; decimals?: string; @@ -84,7 +102,9 @@ const alpha = alt_sc( ); const alphaStr = apply(rep(alpha), (r) => r.join('')); -const spaces = rep_sc(str(' ')); +function spaces(): Parser[]> { + return rep_sc(str(' ')); +} const unicodeStr = rep(tok('char')); @@ -100,6 +120,10 @@ function trimmed(p: Parser[]>): Parser[]> { }); } +function padded(p: Parser): Parser { + return kmid(spaces(), p, spaces()); +} + function anythingTyped(types: string[]) { return types.map((t) => tok(t)).reduce((acc, cur) => alt_sc(cur, acc), fail('no alternatives')); } @@ -145,39 +169,60 @@ function tokenParserToText(p: Parser> | Parser[]>) }); } +const singerIndicator = kleft(tok('char'), str(':')); +const translateParser = kright(str('|'), unicodeStr); + function lrcLine( wordDiv = ' ', legacy = false -): Parser { +): Parser { return alt_sc( legacy ? apply(seq(squareTS, trimmed(rep_sc(anythingTyped(['char', '[', ']', '<', '>'])))), (r) => - ['script_item', { start: r[0], text: joinTokens(r[1]) } as any as ScriptItem] // TODO: Complete this - ) : apply(seq(squareTS, rep_sc(seq(opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']'])))))), (r) => { - const start = r[0]; + ['script_item', { start: r[0], text: joinTokens(r[1]) } as ParserScriptItem] // TODO: Complete this + ) : apply( + seq( + squareTS, + opt_sc(singerIndicator), + rep_sc( + seq( + opt_sc(angleTS), + trimmed(rep_sc(anythingTyped(['char', '[', ']']))) + ) + ), + opt_sc(trimmed(translateParser)) + ), (r) => { + const start = r[0]; + const singerPart = r[1]; + const mainPart = r[2]; + const translatePart = r[3]; - const text = r[1] - .map((s) => joinTokens(s[1])) - .filter((s) => s.trim().length > 0) - .join(wordDiv); + const text = mainPart + .map((s) => joinTokens(s[1])) + .filter((s) => s.trim().length > 0) + .join(wordDiv); - const words = r[1] - .filter((s) => joinTokens(s[1]).trim().length > 0) - .map((s) => { - const wordBegin = s[0]; - const word = s[1]; - let ret: Partial = { start: wordBegin }; - if (word[0]) { - ret.beginIndex = word[0].pos.columnBegin - 1; - } - if (word[word.length - 1]) { - ret.endIndex = word[word.length - 1].pos.columnEnd; - } - return ret as ScriptWordsItem; // TODO: Complete this - }); - return ['script_item', { start, text, words } as any as ScriptItem]; // TODO: Complete this - }), + const words = mainPart + .filter((s) => joinTokens(s[1]).trim().length > 0) + .map((s) => { + const wordBegin = s[0]; + const word = s[1]; + let ret: Partial = { start: wordBegin }; + if (word[0]) { + ret.beginIndex = word[0].pos.columnBegin - 1; + } + if (word[word.length - 1]) { + ret.endIndex = word[word.length - 1].pos.columnEnd; + } + return ret as ScriptWordsItem; // TODO: Complete this + }); + + const singer = singerPart?.text; + const translation = translatePart === undefined ? undefined : joinTokens(translatePart); + + return ['script_item', { start, text, words, singer, translation } as ParserScriptItem]; + }), apply(lrcTag, (r) => ['lrc_tag', r as IDTag]), - apply(seq(spaces, str('#'), unicodeStr), (cmt) => ['comment', cmt[2].join('')] as const), - apply(spaces, (_) => ['empty', null] as const) + apply(seq(spaces(), str('#'), unicodeStr), (cmt) => ['comment', cmt[2].join('')] as const), + apply(spaces(), (_) => ['empty', null] as const) ); } @@ -191,7 +236,7 @@ export function dumpToken(t: Token | undefined): string { export function parseLRC( input: string, { wordDiv, strict, legacy }: { wordDiv?: string; strict?: boolean; legacy?: boolean } = {} -): LrcJsonData { +): ParsedLrc { const tokenizer = buildLexer([ [true, /^\[/gu, '['], [true, /^\]/gu, ']'], @@ -231,5 +276,5 @@ export function parseLRC( default: return acc; } - }, {} as LrcJsonData); + }, {} as ParsedLrc); } diff --git a/src/test/lrcParser.test.ts b/src/test/lrcParser.test.ts index 01ae0af..27c1e3c 100644 --- a/src/test/lrcParser.test.ts +++ b/src/test/lrcParser.test.ts @@ -7,6 +7,8 @@ describe('LRC parser test', () => { const test01Text = test01Buffer.toString('utf-8'); const test02Buffer = fs.readFileSync('./src/test/resources/test-02.lrc'); const test02Text = test02Buffer.toString('utf-8'); + const test03Buffer = fs.readFileSync('./src/test/resources/test-03.lrc'); + const test03Text = test03Buffer.toString('utf-8'); it('Parses test-01.lrc', () => { const result = parseLRC(test01Text, { wordDiv: '', strict: true }); @@ -28,6 +30,11 @@ describe('LRC parser test', () => { expect(result.scripts!![0].words!![1].beginIndex).toBe("[00:00.00] <00:00.04> When <00:00.16> the".indexOf("the")); expect(result.scripts!![0].words!![1].start).toBe(160); }); + it('Parses test-03.lrc', () => { + const result = parseLRC(test03Text, { wordDiv: ' ', strict: true }); + console.log(result.scripts); + expect(result.scripts!![5].translation).toBe("བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ།"); + }); it('Rejects some invalid LRCs', () => { const cases = [ "[<00:00.00>] <00:00.04> When <00:00.16> the", diff --git a/src/test/resources/test-03.lrc b/src/test/resources/test-03.lrc new file mode 100644 index 0000000..8edc547 --- /dev/null +++ b/src/test/resources/test-03.lrc @@ -0,0 +1,77 @@ +[ti: 雪山之眼] +[ar: 洛天依 & 旦增益西] +[al: 游四方] +[tool: 歌词滚动姬 https://lrc-maker.github.io] +[length: 04:17.400] +[00:34.280] 浸透了经卷 记忆的呼喊 +[00:37.800] 雪珠滚落山巅 栽下一个春天 +[00:47.390] 松石敲响玲珑清脆的银花 +[00:51.600] 穿过玛瑙的红霞 +[00:54.430] 在她眼中结编 亘久诗篇 +[01:05.440] བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ། | 在舞池里舞一舞 +[01:08.780] 祝祷转过千年 五色经幡飘飞 +[01:12.040] 奏起悠扬巴叶 任岁月拨弦 +[01:19.130] གཞས་ར་འདི་ལ་གཞས་གཅིག་བཏང་། 我在歌坛献首歌 +[01:22.330] 宫殿 塔尖 彩绘 日月 同辉 +[01:25.810] 那层厚重壁垒化身 蝉翼一片 +[01:29.110] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[01:30.790] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[01:32.510] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[01:34.120] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[01:35.920] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[01:37.630] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[01:39.350] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[01:41.050] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[01:42.740] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[01:44.630] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[01:46.280] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[01:48.010] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[01:49.600] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[01:51.380] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[01:53.070] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[01:54.820] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[01:58.580] སྔོན་དང་པོ་གྲུབ་ཐོབ་ཐང་སྟོང་རྒྱལ་པོས་མཛད་པའི་མཛད་ཚུལ་དུ། དང་པོ་རྔོན་པའི་ས་སྦྱངས་ས་འདུལ། གཉིས་པ་རྒྱ་ལུའི་བྱིན་འབེབས། གསུམ་པ་ལྷ་མོའི་གླུ་གར་སོགས་རིན་ཆེན་གསུང་མགུར་གཞུང་བཟང་མང་པོ་འདུག་སྟེ། དེ་ཡང་མ་ཉུང་གི་ཚིག་ལ་དུམ་མཚམས་གཅིག་ཞུས་པ་བྱུང་བ་ཡིན་པ་ལགས་སོ། 如祖师唐东杰布所著,一有温巴净地,二有甲鲁祈福,三有仙女歌舞,所著繁多,在此简略献之。 +[02:24.240] 浸透了经卷 记忆的呼喊 +[02:27.450] 雪珠滚落山巅 栽下一个春天 +[02:37.090] 松石敲响玲珑清脆的银花 +[02:41.280] 穿过玛瑙的红霞 +[02:44.010] 在她眼中结编 亘久诗篇 +[02:55.250] བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ། 在舞池里舞一舞 +[02:58.410] 祝祷转过千年 五色经幡飘飞 +[03:01.750] 奏起悠扬巴叶 任岁月拨弦 +[03:08.840] གཞས་ར་འདི་ལ་གཞས་གཅིག་བཏང་། 我在歌坛献首歌 +[03:12.050] 宫殿 塔尖 彩绘 日月 同辉 +[03:15.400] 那层厚重壁垒化身 蝉翼一片 +[03:18.850] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:20.480] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:22.210] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:23.910] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:25.662] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:27.391] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:29.096] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:30.789] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:32.496] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:34.175] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:35.876] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:37.606] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:39.290] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:41.030] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:42.679] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:44.455] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:46.176] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:47.910] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:49.625] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:51.293] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:53.005] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[03:54.742] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[03:56.479] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[03:58.159] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[03:59.859] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[04:01.548] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[04:03.312] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[04:05.026] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[04:06.721] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[04:08.479] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 +[04:10.175] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 +[04:11.923] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 +[04:17.400] \ No newline at end of file -- 2.45.2 From dd675ad7103f98352a5100b2c5c13ceb3a3198d3 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 27 Jul 2024 03:07:23 -0500 Subject: [PATCH 7/9] fix: translation and singer parsing Signed-off-by: eternal-flame-AD --- src/lib/lyrics/parser.ts | 5 +++-- src/test/lrcParser.test.ts | 8 ++++++-- src/test/resources/test-03.lrc | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index fed8188..1db4671 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -170,7 +170,7 @@ function tokenParserToText(p: Parser> | Parser[]>) } const singerIndicator = kleft(tok('char'), str(':')); -const translateParser = kright(str('|'), unicodeStr); +const translateParser = kright(tok('|'), unicodeStr); function lrcLine( wordDiv = ' ', legacy = false @@ -181,7 +181,7 @@ function lrcLine( ) : apply( seq( squareTS, - opt_sc(singerIndicator), + opt_sc(padded(singerIndicator)), rep_sc( seq( opt_sc(angleTS), @@ -242,6 +242,7 @@ export function parseLRC( [true, /^\]/gu, ']'], [true, /^/gu, '>'], + [true, /^\|/gu, '|'], [true, /^./gu, 'char'] ]); diff --git a/src/test/lrcParser.test.ts b/src/test/lrcParser.test.ts index 27c1e3c..791c31a 100644 --- a/src/test/lrcParser.test.ts +++ b/src/test/lrcParser.test.ts @@ -32,8 +32,12 @@ describe('LRC parser test', () => { }); it('Parses test-03.lrc', () => { const result = parseLRC(test03Text, { wordDiv: ' ', strict: true }); - console.log(result.scripts); - expect(result.scripts!![5].translation).toBe("བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ།"); + expect(result.scripts!![5].text).toBe("བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ།"); + expect(result.scripts!![5].translation).toBe("在舞池里舞一舞"); + expect(result.scripts!![6].text).toBe("祝祷转过千年 五色经幡飘飞"); + expect(result.scripts!![6].singer).toBe("a"); + expect(result.scripts!![11].singer).toBeUndefined(); + expect(result.scripts!![11].translation).toBe("我们在此相聚"); }); it('Rejects some invalid LRCs', () => { const cases = [ diff --git a/src/test/resources/test-03.lrc b/src/test/resources/test-03.lrc index 8edc547..20a669c 100644 --- a/src/test/resources/test-03.lrc +++ b/src/test/resources/test-03.lrc @@ -8,13 +8,13 @@ [00:47.390] 松石敲响玲珑清脆的银花 [00:51.600] 穿过玛瑙的红霞 [00:54.430] 在她眼中结编 亘久诗篇 -[01:05.440] བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ། | 在舞池里舞一舞 -[01:08.780] 祝祷转过千年 五色经幡飘飞 +[01:05.440] a: བྲོ་ར་འདི་ལ་བྲོ་ཅིག་འཁྲབ། | 在舞池里舞一舞 +[01:08.780] a: 祝祷转过千年 五色经幡飘飞 [01:12.040] 奏起悠扬巴叶 任岁月拨弦 [01:19.130] གཞས་ར་འདི་ལ་གཞས་གཅིག་བཏང་། 我在歌坛献首歌 [01:22.330] 宫殿 塔尖 彩绘 日月 同辉 [01:25.810] 那层厚重壁垒化身 蝉翼一片 -[01:29.110] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། 我们在此相聚 +[01:29.110] ང་ཚོ་འདི་ལ་འཛོམས་འཛོམས། | 我们在此相聚 [01:30.790] གཏན་དུ་འཛོམས་རྒྱུ་བྱུང་ན། 希望可以常聚 [01:32.510] གཏན་དུ་འཛོམས་པའི་མི་ལ། 在此相聚的人们 [01:34.120] སྙུན་གཞི་གོད་ཆགས་མ་གཏོང༌། 祝愿平安富足 -- 2.45.2 From 9e388b66ce794467bf1e82cb58155b1203f18540 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Sat, 27 Jul 2024 16:53:05 -0500 Subject: [PATCH 8/9] handle alternative line ends Signed-off-by: eternal-flame-AD --- src/lib/lyrics/parser.ts | 20 ++++++++++---------- src/test/lrcParser.test.ts | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index 1db4671..328f5aa 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -26,7 +26,7 @@ interface ParserScriptItem { singer?: string; } -export interface ScriptItem extends ParserScriptItem{ +export interface ScriptItem extends ParserScriptItem { end: number; chorus?: string; } @@ -64,10 +64,10 @@ interface IDTag { } function convertTimeToMs({ - mins, - secs, - decimals - }: { + mins, + secs, + decimals +}: { mins?: number | string; secs?: number | string; decimals?: string; @@ -180,11 +180,11 @@ function lrcLine( ['script_item', { start: r[0], text: joinTokens(r[1]) } as ParserScriptItem] // TODO: Complete this ) : apply( seq( - squareTS, + squareTS, opt_sc(padded(singerIndicator)), rep_sc( seq( - opt_sc(angleTS), + opt_sc(angleTS), trimmed(rep_sc(anythingTyped(['char', '[', ']']))) ) ), @@ -214,10 +214,10 @@ function lrcLine( } return ret as ScriptWordsItem; // TODO: Complete this }); - + const singer = singerPart?.text; const translation = translatePart === undefined ? undefined : joinTokens(translatePart); - + return ['script_item', { start, text, words, singer, translation } as ParserScriptItem]; }), apply(lrcTag, (r) => ['lrc_tag', r as IDTag]), @@ -247,7 +247,7 @@ export function parseLRC( ]); const lines = input - .split('\n') + .split(/\r\n|\r|\n/gu) .filter((line) => line.trim().length > 0) .map((line) => tokenizer.parse(line)); diff --git a/src/test/lrcParser.test.ts b/src/test/lrcParser.test.ts index 791c31a..f3193a2 100644 --- a/src/test/lrcParser.test.ts +++ b/src/test/lrcParser.test.ts @@ -9,15 +9,22 @@ describe('LRC parser test', () => { const test02Text = test02Buffer.toString('utf-8'); const test03Buffer = fs.readFileSync('./src/test/resources/test-03.lrc'); const test03Text = test03Buffer.toString('utf-8'); - it('Parses test-01.lrc', () => { - const result = parseLRC(test01Text, { wordDiv: '', strict: true }); - expect(result.ar).toBe("洛天依"); - expect(result.ti).toBe("中华少女·终"); - expect(result.al).toBe("中华少女"); - expect(result["tool"]).toBe("歌词滚动姬 https://lrc-maker.github.io"); - expect(result.scripts!![1].text).toBe("因果与恩怨牵杂等谁来诊断"); - expect(result.scripts!![1].start).toBe(49000 + 588); + const lf_alternatives = ['\n', '\r\n', '\r']; + + it('Parses test-01.lrc', () => { + for (const lf of lf_alternatives) { + const text = test01Text.replaceAll('\n', lf); + + const result = parseLRC(text, { wordDiv: '', strict: true }); + + expect(result.ar).toBe("洛天依"); + expect(result.ti).toBe("中华少女·终"); + expect(result.al).toBe("中华少女"); + expect(result["tool"]).toBe("歌词滚动姬 https://lrc-maker.github.io"); + expect(result.scripts!![1].text).toBe("因果与恩怨牵杂等谁来诊断"); + expect(result.scripts!![1].start).toBe(49000 + 588); + } }) it('Parses test-02.lrc', () => { const result = parseLRC(test02Text, { wordDiv: ' ', strict: true }); -- 2.45.2 From 8b541818c9fae953e4091352b39af57c8eaf3adf Mon Sep 17 00:00:00 2001 From: alikia2x Date: Sun, 28 Jul 2024 18:30:56 +0800 Subject: [PATCH 9/9] fix: full-feature LRC parser by umechi migrated into main app --- package.json | 2 +- src/lib/lyrics/parser.ts | 32 +++++++++++++++++++++++++++---- src/routes/play/[id]/+page.svelte | 16 ++++++++++++---- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1b99d1e..a627f21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aquavox", - "version": "1.12.14", + "version": "1.12.15", "private": false, "scripts": { "dev": "vite dev", diff --git a/src/lib/lyrics/parser.ts b/src/lib/lyrics/parser.ts index 328f5aa..68cb401 100644 --- a/src/lib/lyrics/parser.ts +++ b/src/lib/lyrics/parser.ts @@ -51,11 +51,13 @@ export interface LrcMetaData { export interface ParsedLrc extends LrcMetaData { scripts?: ParserScriptItem[]; + [key: string]: any; } export interface LrcJsonData extends LrcMetaData { scripts?: ScriptItem[]; + [key: string]: any; } @@ -64,10 +66,10 @@ interface IDTag { } function convertTimeToMs({ - mins, - secs, - decimals -}: { + mins, + secs, + decimals + }: { mins?: number | string; secs?: number | string; decimals?: string; @@ -102,6 +104,7 @@ const alpha = alt_sc( ); const alphaStr = apply(rep(alpha), (r) => r.join('')); + function spaces(): Parser[]> { return rep_sc(str(' ')); } @@ -279,3 +282,24 @@ export function parseLRC( } }, {} as ParsedLrc); } + +export default function lrcParser(lrc: string): LrcJsonData { + const parsedLrc = parseLRC(lrc, { wordDiv: '', strict: true }); + if (parsedLrc.scripts === undefined) { + return parsedLrc as LrcJsonData; + } + let finalLrc: LrcJsonData = parsedLrc as LrcJsonData; + let lyrics: ScriptItem[] = []; + let i = 0; + while (i < parsedLrc.scripts.length - 1) { + let lyricLine = parsedLrc.scripts[i] as ScriptItem; + lyricLine.start/=1000; + lyricLine.end = parsedLrc.scripts[i+1].start / 1000; + if (parsedLrc.scripts[i+1].text.trim() === "") { + i+=2; + } else i++; + lyrics.push(lyricLine); + } + finalLrc.scripts = lyrics; + return finalLrc; +} \ No newline at end of file diff --git a/src/routes/play/[id]/+page.svelte b/src/routes/play/[id]/+page.svelte index a68d275..5d6f7f9 100644 --- a/src/routes/play/[id]/+page.svelte +++ b/src/routes/play/[id]/+page.svelte @@ -8,14 +8,14 @@ import extractFileName from '$lib/extractFileName'; import localforage from 'localforage'; import { writable } from 'svelte/store'; - import lrcParser, { type LrcJsonData } from 'lrc-parser-ts'; + import lrcParser, { type LrcJsonData } from '$lib/lyrics/parser'; import userAdjustingProgress from '$lib/state/userAdjustingProgress'; import type { IAudioMetadata } from 'music-metadata-browser'; import { onMount } from 'svelte'; import progressBarRaw from '$lib/state/progressBarRaw'; const audioId = $page.params.id; - let audioPlayer: HTMLAudioElement; + let audioPlayer: HTMLAudioElement | null = null; let volume = 1; let name = ''; let singer = ''; @@ -44,22 +44,26 @@ ] }); ms.setActionHandler('play', function () { + if (audioPlayer===null) return; audioPlayer.play(); paused = false; }); ms.setActionHandler('pause', function () { + if (audioPlayer===null) return; audioPlayer.pause(); paused = true; }); ms.setActionHandler('seekbackward', function () { + if (audioPlayer===null) return; if (audioPlayer.currentTime > 4) { audioPlayer.currentTime = 0; } }); ms.setActionHandler('previoustrack', function () { + if (audioPlayer===null) return; if (audioPlayer.currentTime > 4) { audioPlayer.currentTime = 0; } @@ -81,6 +85,7 @@ prepared.push('cover'); }); localforage.getItem(`${audioId}-file`, function (err, file) { + if (audioPlayer===null) return; if (file) { const f = file as File; audioFile = f; @@ -105,6 +110,7 @@ } function playAudio() { + if (audioPlayer===null) return; if (audioPlayer.duration) { duration = audioPlayer.duration; } @@ -114,7 +120,7 @@ } $: { - if (!launched) { + if (!launched && audioPlayer) { const requirements = ['name', 'file', 'cover']; let flag = true; for (const r of requirements) { @@ -152,6 +158,7 @@ $: { clearInterval(mainInterval); mainInterval = setInterval(() => { + if (audioPlayer===null) return; if ($userAdjustingProgress === false) currentProgress = audioPlayer.currentTime; progressBarRaw.set(audioPlayer.currentTime); @@ -159,6 +166,7 @@ } onMount(() => { + if (audioPlayer===null) return; audioPlayer.volume = localStorage.getItem('volume') ? Number(localStorage.getItem('volume')) : 1; }); @@ -175,7 +183,7 @@ - {name} - Aquavox + {name} - AquaVox -- 2.45.2