mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Fallback to LyricWikia if lyrics not found on Genius
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
from spotdl.lyrics.providers.lyricwikia_wrapper import LyricWikia
|
||||
from spotdl.lyrics.providers.genius import Genius
|
||||
from spotdl.lyrics.providers.lyricwikia_wrapper import LyricWikia
|
||||
|
||||
LyricClasses = (Genius, LyricWikia)
|
||||
|
||||
@@ -11,12 +11,14 @@ import functools
|
||||
|
||||
from spotdl import const
|
||||
from spotdl import internals
|
||||
from spotdl.lyrics.providers import LyricWikia
|
||||
from spotdl.lyrics.providers import LyricClasses
|
||||
from spotdl.lyrics.exceptions import LyricsNotFound
|
||||
|
||||
spotify = None
|
||||
|
||||
|
||||
|
||||
|
||||
def generate_token():
|
||||
""" Generate the token. """
|
||||
credentials = oauth2.SpotifyClientCredentials(
|
||||
@@ -75,12 +77,16 @@ def generate_metadata(raw_song):
|
||||
meta_tags[u"total_tracks"] = album["tracks"]["total"]
|
||||
|
||||
log.debug("Fetching lyrics")
|
||||
track = LyricWikia(meta_tags["artists"][0]["name"], meta_tags["name"])
|
||||
meta_tags["lyrics"] = None
|
||||
|
||||
try:
|
||||
meta_tags["lyrics"] = track.get_lyrics()
|
||||
except LyricsNotFound:
|
||||
meta_tags["lyrics"] = None
|
||||
for LyricClass in LyricClasses:
|
||||
track = LyricClass(meta_tags["artists"][0]["name"], meta_tags["name"])
|
||||
try:
|
||||
meta_tags["lyrics"] = track.get_lyrics()
|
||||
except LyricsNotFound:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
# Some sugar
|
||||
meta_tags["year"], *_ = meta_tags["release_date"].split("-")
|
||||
|
||||
Reference in New Issue
Block a user