feat: add lrclib and genius providers (#5)
* feat: lrclib and genius providers * revert `prepend_header` to true * change providers order --------- Co-authored-by: mrsobakin <68982655+mrsobakin@users.noreply.github.com>
This commit is contained in:
parent
d6b36886ba
commit
bad4a355e8
8 changed files with 103 additions and 19 deletions
18
lrc_dl/providers/lrclib.py
Normal file
18
lrc_dl/providers/lrclib.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from typing import Optional
|
||||
import httpx
|
||||
|
||||
from lrc_dl.core import Song, AbstractProvider
|
||||
from lrc_dl.registry import lyrics_provider
|
||||
|
||||
@lyrics_provider
|
||||
class LrcLib(AbstractProvider):
|
||||
name = "lrclib"
|
||||
|
||||
def fetch_lyrics(self, song: Song, with_album = True) -> Optional[str]:
|
||||
r = httpx.get("https://lrclib.net/api/get", params={
|
||||
'track_name': song.title,
|
||||
'artist_name': song.artist,
|
||||
'album_name': song.album if with_album else None,
|
||||
}).json()
|
||||
|
||||
return r.get('syncedLyrics') or r.get('plainLyrics') or (self.fetch_lyrics(song, False) if with_album else None)
|
Loading…
Add table
Add a link
Reference in a new issue