misc
This commit is contained in:
@@ -78,7 +78,42 @@ class RedisCache:
|
||||
if fuzzy:
|
||||
artist = " ".join([f"(%{artist_word}%)" for artist_word in artist.split(" ")])
|
||||
song = " ".join([f"(%{song_word}%)" for song_word in song.split(" ")])
|
||||
return (artist, song)
|
||||
return (artist, song)
|
||||
|
||||
async def increment_found_count(self, src: str) -> None:
|
||||
"""
|
||||
Increment the found count for a source
|
||||
Args:
|
||||
src (str): The source to increment
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
try:
|
||||
src = src.strip().lower()
|
||||
await self.redis_client.incr(f"returned:{src}")
|
||||
except Exception as e:
|
||||
await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}")
|
||||
traceback.print_exc()
|
||||
|
||||
async def get_found_counts(self) -> dict:
|
||||
"""
|
||||
Get found counts for all sources
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
dict: In the form {'source': count, 'source2': count, ...}
|
||||
"""
|
||||
try:
|
||||
sources: list = ["cache", "lrclib", "genius"]
|
||||
counts: dict = {}
|
||||
for src in sources:
|
||||
src_found_count = await self.redis_client.get(f"returned:{src}")
|
||||
counts[src] = src_found_count
|
||||
logging.info("Returning: %s", counts)
|
||||
return counts
|
||||
except Exception as e:
|
||||
await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}")
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
async def search(self, **kwargs) -> list[tuple]:
|
||||
|
||||
Reference in New Issue
Block a user