From b782ae5685741f4cceb6d3fcef9c3617fc64ecf7 Mon Sep 17 00:00:00 2001 From: orfelorfel23 Date: Sat, 12 Sep 2026 20:30:43 +0200 Subject: [PATCH] fix(metadata): direct parsing of tempo and key_of from GetSongBPM API search response --- server/routes/metadata.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/server/routes/metadata.js b/server/routes/metadata.js index c3470d5..97d2df9 100644 --- a/server/routes/metadata.js +++ b/server/routes/metadata.js @@ -72,18 +72,16 @@ router.get('/', async (req, res) => { }); const searchResults = gsbRes.data && gsbRes.data.search; - if (searchResults && searchResults.length > 0) { - const songId = searchResults[0].song_id; - if (songId) { - const songRes = await axios.get('https://api.getsong.co/song/', { - params: { api_key: process.env.GETSONGBPM_API_KEY, id: songId }, - timeout: 4000 - }); - if (songRes.data && songRes.data.song) { - bpm = songRes.data.song.tempo; - const keyStr = songRes.data.song.key_of; - camelotKey = standardizeKey(keyStr); - } + if (Array.isArray(searchResults) && searchResults.length > 0) { + const song = searchResults[0]; + if (song.tempo) { + bpm = parseFloat(song.tempo); + } + if (song.key_of) { + camelotKey = standardizeKey(song.key_of); + } + if (song.artist && song.artist.genres && tags.length === 0) { + tags = song.artist.genres.slice(0, 4); } } } catch (err) {