tranxuanthang / lrcget

Utility for mass-downloading LRC synced lyrics for your offline music library.
MIT License
540 stars 20 forks source link

Manual search #2

Closed Dr-Blank closed 9 months ago

Dr-Blank commented 1 year ago

There are some songs where I know the lyrics exists on musixmatch, it's just that the metadata might be a little off which fails the matching of song to your database.

If there was a way to modify the search query, e.g. artist or song name, such that I could try matching to your database and retrieve the lyrics.

This is a wonderful piece of software, thank you for making this. It relieved me of so much pain of finding lyrics for every song individually and renaming the file to match the song (that is just brilliant)!!

tranxuanthang commented 1 year ago

I'm working on a official homepage for lrclib which including a search feature, but in the meantime you can use these APIs to find the lyrics you want:

For example:

Dr-Blank commented 1 year ago

This api is awesome. I wish there was a plugin for beets which used this api. It would be splendid.

johnhatch commented 1 year ago

Agreed the API and program are great! Thanks @tranxuanthang :) I added Lrclib to my beets lyrics plugin and it works well. It's handy to run lrclib as the sole lyrics source with -f so existing plain lyrics are replaced with synced versions, if available. I modified my beets install directly at Python39\Lib\site-packages\beetsplug\lyrics.py

Added a basic Backend for Lrclib above the existing Tekstowo one (the api call I borrowed from what lrcget uses in main.rs)

class Lrclib(Backend):
    def fetch(self, artist, title, album, length):
        url = 'https://lrclib.net/api/get?artist_name={}&track_name={}&album_name={}&duration={}'.format(artist, title, album, length)
        try:
            response = requests.get(url)
        except requests.RequestException as exc:
            self._log.debug('Lrclib API request failed: {0}', exc)
            return None
        try:
            return response.json()['syncedLyrics']
        except json.decoder.JSONDecodeError as exc:
            self._log.debug('Lrclib API request failed: {0}', exc)
            return None
        except KeyError:
            return None

We add album/duration parameters to all methods, the other backends don't use these but it's nice lrclib is accurate in this way

- lyrics = [self.get_lyrics(artist, title) for title in titles]
+ lyrics = [self.get_lyrics(artist, title, item.album, round(item.length)) for title in titles]

- def get_lyrics(self, artist, title):
+ def get_lyrics(self, artist, title, album, length):

- lyrics = backend.fetch(artist, title)
+ lyrics = backend.fetch(artist, title, album, length)

# there are multiple instances of this
- def fetch(self, artist, title):
+ def fetch(self, artist, title, album, length):

And add it as a source, and enable in your config :)

-   SOURCES = ['google', 'musixmatch', 'genius', 'tekstowo']
+   SOURCES = ['google', 'musixmatch', 'genius', 'tekstowo', 'lrclib']
    SOURCE_BACKENDS = {
        'google': Google,
        'musixmatch': MusiXmatch,
        'genius': Genius,
        'tekstowo': Tekstowo,
+       'lrclib': Lrclib
    }
Dr-Blank commented 1 year ago

I added Lrclib to my beets lyrics plugin

Sounds amazing, I'll have to try once I get home!

tranxuanthang commented 9 months ago

Manual search feature is now available in v0.2.1:

https://github.com/tranxuanthang/lrcget/releases

You can also search for lyrics by visiting LRCLIB homepage:

https://lrclib.net