progress -- change get to search for lrclib

This commit is contained in:
2025-01-14 10:04:05 -05:00
parent 9d8d38081a
commit f86d5a4fec
6 changed files with 113 additions and 8 deletions

View File

@@ -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