Skip to content

Commit 3640527

Browse files
committed
fix(synced-lyrics): LRCLIB returns 0 results if album is undefined
- inspired by #2381
1 parent 3326582 commit 3640527

File tree

1 file changed

+7
-4
lines changed
  • src/plugins/synced-lyrics/renderer/lyrics

1 file changed

+7
-4
lines changed

src/plugins/synced-lyrics/renderer/lyrics/fetch.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ export const makeLyricsRequest = async (extractedSongInfo: SongInfo) => {
5252
const songData: Parameters<typeof getLyricsList>[0] = {
5353
title: `${extractedSongInfo.title}`,
5454
artist: `${extractedSongInfo.artist}`,
55-
album: `${extractedSongInfo.album}`,
5655
songDuration: extractedSongInfo.songDuration,
5756
};
5857

58+
if (extractedSongInfo.album) {
59+
songData.album = extractedSongInfo.album;
60+
}
61+
5962
let lyrics;
6063
try {
6164
lyrics = await getLyricsList(songData);
@@ -78,9 +81,9 @@ export const getLyricsList = async (
7881
track_name: songData.title,
7982
});
8083

81-
query.set('album_name', songData.album!);
82-
if (query.get('album_name') === 'undefined') {
83-
query.delete('album_name');
84+
85+
if (songData.album) {
86+
query.set('album_name', songData.album);
8487
}
8588

8689
let url = `https://lrclib.net/api/search?${query.toString()}`;

0 commit comments

Comments
 (0)