progress -- change get to search for lrclib
This commit is contained in:
@@ -8,6 +8,7 @@ sys.path.insert(1,'..')
|
||||
sys.path.insert(1,'..')
|
||||
from . import cache
|
||||
from . import genius
|
||||
from . import lrclib
|
||||
|
||||
class Aggregate:
|
||||
"""Aggregate all source methods"""
|
||||
@@ -20,15 +21,21 @@ class Aggregate:
|
||||
async def search(self, artist: str, song: str) -> Optional[LyricsResult]:
|
||||
cache_search = cache.Cache()
|
||||
genius_search = genius.Genius()
|
||||
lrclib_search = lrclib.LRCLib()
|
||||
search = None
|
||||
if "cache" not in self.exclude_methods:
|
||||
# First, try cache
|
||||
search = await cache_search.search(artist, song)
|
||||
if not search:
|
||||
print("Cache: NOT FOUND!")
|
||||
# Then try Genius
|
||||
if "genius" in self.exclude_methods:
|
||||
return # Skipped last possible source, return None
|
||||
search = await genius_search.search(artist, song)
|
||||
# Then try LRCLib
|
||||
if "lrclib" not in self.exclude_methods:
|
||||
search = await lrclib_search.search(artist, song)
|
||||
if not search:
|
||||
print("LRCLib: Not found!")
|
||||
# Then try Genius
|
||||
if "genius" in self.exclude_methods:
|
||||
return # Skipped last possible source, return None
|
||||
search = await genius_search.search(artist, song)
|
||||
|
||||
return search
|
||||
|
||||
Reference in New Issue
Block a user