Bellisario / musicale

Musicale, music with style
https://musicale.tk
MIT License
106 stars 7 forks source link

feature: lyrics support #166

Open ludg1e opened 11 months ago

ludg1e commented 11 months ago

Hello, I really love this project and use it a lot as a reliable alternative to yt-music.

Is there any plan to add lyrics support? (even if isn't synced) Maybe you could fetch the lyrics with web scraping from Genius or Musixmatch based on the song name (though this may lead to errors sometimes)

Thank you and have a nice day!

ludg1e commented 11 months ago

Usually on Genius.com all lyrics pages follow the same scheme: https://genius.com/artist-name-song-name-lyrics Then we could select the second child of the div with id "lyrics-root" (seems to follow the same pattern always) First child of "lyrics-root" is lyrics header with song title and contributors, while second child is the full lyrics separated with <br> tags

For musixmatch.com it seems to follow this scheme: https://musixmatch.com/lyrics/artist-name/song-name Though the artist name (or ID) could be slightly different than the original on other platforms (e.g JVKE on musixmatch is JVKE-4) Lyrics are inside an span on the div with class "mxm-lyrics"

ludg1e commented 11 months ago

I understand that web scraping is a very rudimentary way of doing things as well it can lead to multiple issues (rate-limited scraping from the website in case of lots of users) I'm just giving an idea of how it could be possible to implement this, though it may not be the best way

Bellisario commented 10 months ago

Hello, I really love this project and use it a lot as a reliable alternative to yt-music.

Hello, glad you love the project!

Is there any plan to add lyrics support?

Of course, I had already an idea about adding lyrics, but I always stopped because I want to keep Musicale a client-side only application.\ Scraping content from other sites is blocked by CORS and the only solution is to use a server. In this case, I would like to create a new API endpoint hosted on Deno Deploy which can be used by Musicale to fetch lyrics.

I already experimented with this library, which offers built-in scraping from Musixmatch.\ Synced music instead it's practically impossible without getting a paid developer API key directly from Musixmatch...


Another solution, which I would prefer, is to have an API endpoint accessible from Piped (used on Musicale), which already scrapes the content from YouTube Music. I'm going to open a feature request and will see... in case of a negative feedback, I will implement myself the API...