Add additional methods to fetch lyrics

The following inputs can now be used to fetch lyrics:
* artist and track names
* search query
* direct url
This commit is contained in:
Ritiek Malhotra
2020-04-08 21:43:58 +05:30
parent 51da0b7a29
commit 47247f7250
7 changed files with 210 additions and 76 deletions

View File

@@ -5,17 +5,20 @@ from spotdl.lyrics.exceptions import LyricsNotFoundError
class LyricWikia(LyricBase):
def __init__(self, artist, track):
self.artist = artist
self.track = track
def from_query(self, query, linesep="\n", timeout=None):
raise NotImplementedError
def get_lyrics(self, linesep="\n", timeout=None):
def from_artist_and_track(self, artist, track, linesep="\n", timeout=None):
"""
Returns the lyric string for the given artist and track.
"""
try:
lyrics = lyricwikia.get_lyrics(self.artist, self.track, linesep, timeout)
lyrics = lyricwikia.get_lyrics(artist, track, linesep, timeout)
except lyricwikia.LyricsNotFound as e:
raise LyricsNotFoundError(e.args[0])
else:
return lyrics
return lyrics
def from_url(self, url, linesep="\n", timeout=None):
raise NotImplementedError