From b55814694c3d5ca1e2426f4fa023475f6c01cbde Mon Sep 17 00:00:00 2001 From: Kye Fenton Date: Mon, 2 Jun 2025 13:56:06 +0930 Subject: [PATCH] Enhancement: Support getting LRC lyrics from a "Lyrics" subfolder --- src/app/services/lyrics/lrc-lyrics-getter.ts | 26 +++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/app/services/lyrics/lrc-lyrics-getter.ts b/src/app/services/lyrics/lrc-lyrics-getter.ts index 76c06af41..7254c126e 100644 --- a/src/app/services/lyrics/lrc-lyrics-getter.ts +++ b/src/app/services/lyrics/lrc-lyrics-getter.ts @@ -41,23 +41,19 @@ export class LrcLyricsGetter implements ILyricsGetter { } private getLrcFilePath(track: TrackModel): string { - const trackPathWithoutExtension: string = this.fileAccess.getPathWithoutExtension(track.path); - let possibleLrcFilePath: string = `${trackPathWithoutExtension}.lrc`; + const trackPath: string = this.fileAccess.getDirectoryPath(track.path); + const trackFileNameWithoutExtension: string = this.fileAccess.getFileNameWithoutExtension(track.path); + const lrcExtensions: string[] = ['.lrc', '.Lrc', '.LRC'] + const possibleFolders: string[] = [`${trackPath}`, `${trackPath}\\lyrics`, `${trackPath}\\Lyrics`, `${trackPath}\\LYRICS`] - if (this.fileAccess.pathExists(possibleLrcFilePath)) { - return possibleLrcFilePath; - } - - possibleLrcFilePath = `${trackPathWithoutExtension}.Lrc`; - - if (this.fileAccess.pathExists(possibleLrcFilePath)) { - return possibleLrcFilePath; - } + for (var folder of possibleFolders) { + for (var ext of lrcExtensions) { + let possibleLrcFilePath: string = `${folder}\\${trackFileNameWithoutExtension}${ext}`; - possibleLrcFilePath = `${trackPathWithoutExtension}.LRC`; - - if (this.fileAccess.pathExists(possibleLrcFilePath)) { - return possibleLrcFilePath; + if (this.fileAccess.pathExists(possibleLrcFilePath)) { + return possibleLrcFilePath; + } + } } return '';