Skip to content

Commit

Permalink
Fixed a bug where manually synced lyrics aren't saved to songs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandakan committed Sep 7, 2024
1 parent 2757dc3 commit 9f85e6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
'react-refresh/only-export-components': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'import/no-unresolved': 'off',
'import/named': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'react/no-unescaped-entities': 'off',
'@typescript-eslint/no-unused-vars': 'warn'
Expand Down
5 changes: 4 additions & 1 deletion src/main/core/getSongLyrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ const fetchLyricsFromLRCFile = async (songPath: string) => {
(await readFileData(customLrcFilePathWithoutExtension));
}

if (!lyricsInLrcFormat) throw Error('No lrc lyrics files found.');
if (!lyricsInLrcFormat) {
log('No lrc lyrics files found.');
return undefined;
}

const parsedLyrics = parseLyrics(lyricsInLrcFormat);
return parsedLyrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,33 @@ const convertLyricsStrToObj = (
const lyrics = metadataLines.concat(lines).join('\n');

const isSynced = isLyricsSynced(lyrics);
const syncedLyrics: SyncedLyricLine[] | undefined =
const parsedLyrics: LyricLine[] | undefined =
lyricsLines.length > 0
? lyricsLines.map((line) => {
return {
text: Array.isArray(line.text)
originalText: Array.isArray(line.text)
? line.text.map((textLine) => textLine.text).join(' ')
: line.text,
translatedTexts: [],
isEnhancedSynced: false,
start: line.start || 0,
end: line.end || 0
};
})
: undefined;
: [];

const obj: SongLyrics = {
title,
source: 'IN_SONG_LYRICS',
lyrics: {
isTranslated: false,
isSynced,
unparsedLyrics: lyrics,
lyrics: lines,
syncedLyrics,
parsedLyrics,
offset: 0
},
lyricsType: isSynced ? 'SYNCED' : 'UN_SYNCED',
isOfflineLyricsAvailable: false,
isTranslated: false
isOfflineLyricsAvailable: false
};
return obj;
};
Expand Down

0 comments on commit 9f85e6f

Please sign in to comment.