Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual search #2

Closed
Dr-Blank opened this issue Nov 23, 2022 · 5 comments
Closed

Manual search #2

Dr-Blank opened this issue Nov 23, 2022 · 5 comments

Comments

@Dr-Blank
Copy link

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
Copy link
Owner

tranxuanthang commented Nov 25, 2022

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:

  • https://lrclib.net/api/search?q={query}
  • https://lrclib.net/api/get/{id}

For example:

@Dr-Blank
Copy link
Author

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

@johnhatch
Copy link

johnhatch commented Mar 16, 2023

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
Copy link
Author

I added Lrclib to my beets lyrics plugin

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

@tranxuanthang
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants