fix(metadata): direct parsing of tempo and key_of from GetSongBPM API search response

This commit is contained in:
Jannik committed 2026-09-12 20:30:43 +02:00
1 parent c800429318
commit b782ae5685
1 file changed
+10 -12
+10 -12
View File
@@ -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) {