mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2026-02-10 19:39:25 +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.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 const
|
||||||
from spotdl import internals
|
from spotdl import internals
|
||||||
from spotdl.lyrics.providers import LyricWikia
|
from spotdl.lyrics.providers import LyricClasses
|
||||||
from spotdl.lyrics.exceptions import LyricsNotFound
|
from spotdl.lyrics.exceptions import LyricsNotFound
|
||||||
|
|
||||||
spotify = None
|
spotify = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generate_token():
|
def generate_token():
|
||||||
""" Generate the token. """
|
""" Generate the token. """
|
||||||
credentials = oauth2.SpotifyClientCredentials(
|
credentials = oauth2.SpotifyClientCredentials(
|
||||||
@@ -75,12 +77,16 @@ def generate_metadata(raw_song):
|
|||||||
meta_tags[u"total_tracks"] = album["tracks"]["total"]
|
meta_tags[u"total_tracks"] = album["tracks"]["total"]
|
||||||
|
|
||||||
log.debug("Fetching lyrics")
|
log.debug("Fetching lyrics")
|
||||||
track = LyricWikia(meta_tags["artists"][0]["name"], meta_tags["name"])
|
meta_tags["lyrics"] = None
|
||||||
|
|
||||||
try:
|
for LyricClass in LyricClasses:
|
||||||
meta_tags["lyrics"] = track.get_lyrics()
|
track = LyricClass(meta_tags["artists"][0]["name"], meta_tags["name"])
|
||||||
except LyricsNotFound:
|
try:
|
||||||
meta_tags["lyrics"] = None
|
meta_tags["lyrics"] = track.get_lyrics()
|
||||||
|
except LyricsNotFound:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
# Some sugar
|
# Some sugar
|
||||||
meta_tags["year"], *_ = meta_tags["release_date"].split("-")
|
meta_tags["year"], *_ = meta_tags["release_date"].split("-")
|
||||||
|
|||||||
Reference in New Issue
Block a user