HelloWorld017 / node-alsong

An alsong lyric finder for node
16 stars 2 forks source link

How to search for songs? #2

Closed dexbyte closed 3 years ago

dexbyte commented 4 years ago

How can we search for the song using alsong API and then use the correct information from the search to fetch the lyrics. Most of the time the artist and title can be different from what's stored in alsong API.

HelloWorld017 commented 3 years ago

Sorry for the late answer.

In the Alsong DB, there might be multiple lyrics for same lyric. ex) There are lyrics for 'ヨルシカ', 'ただ君に晴れ', '요루시카', '그저 네게 맑아라' (Same artist / title but in Japanese, English)

To search through the DB, you can use alsong(artist, title, { page: i }) and iterate over the results until you find the song you want to fetch. If the song you want to find doesn't exist in the results, it means that the song is not in the Alsong DB.

Also, if the music file is available, using alsong(music) might be better as it checks for the lyric using the music file. So the lyric might match with the music, regardless of the title and artist and also you can get the correct title (strTitle) and artist name (strArtistName) from the lyric object.