From 2e179ca7e6eb99e2fd96ccf736ac7f06486bddaa Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 26 Jan 2025 17:56:04 -0500 Subject: [PATCH] notify changes --- lyric_search/sources/aggregate.py | 2 ++ lyric_search/sources/redis_cache.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lyric_search/sources/aggregate.py b/lyric_search/sources/aggregate.py index 2d9d822..1561abc 100644 --- a/lyric_search/sources/aggregate.py +++ b/lyric_search/sources/aggregate.py @@ -71,6 +71,8 @@ class Aggregate: if plain: # do not record LRC fails try: await self.redis_cache.increment_found_count("failed") + self.notifier.send("WARNING", + f"Could not find {artist} - {song} via queried sources.") except Exception as e: traceback.print_exc() logging.info("Could not increment redis failed counter: %s", diff --git a/lyric_search/sources/redis_cache.py b/lyric_search/sources/redis_cache.py index 32e2dd0..89b4ec1 100644 --- a/lyric_search/sources/redis_cache.py +++ b/lyric_search/sources/redis_cache.py @@ -149,8 +149,8 @@ class RedisCache: if not search_res_out: logging.debug("Redis: Normal search failed, trying with fuzzy search") - (fuzzy_artist, fuzzy_song) = self.sanitize_input(artist=artist, - song=song, fuzzy=True) + (fuzzy_artist, fuzzy_song) = self.sanitize_input(artist=artist.split(" ")[0:5], + song=song.split(" ")[0:6], fuzzy=True) search_res = await self.redis_client.ft().search(Query( f"@artist:{fuzzy_artist} @song:{fuzzy_song}" )) @@ -169,8 +169,11 @@ class RedisCache: await self.notifier.send("WARNING", f"Redis cache miss for: \n## *{artist} - {song}*") return search_res_out except Exception as e: - await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}\nSearch was: {artist} - {song}") traceback.print_exc() + if fuzzy_artist and fuzzy_song: + await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}\nSearch was: {artist} - {song}; fuzzy: {fuzzy_artist} - {fuzzy_song}") + else: + await self.notifier.send(f"ERROR @ {__file__.rsplit("/", maxsplit=1)[-1]}", f"{str(e)}\nSearch was: {artist} - {song}; fuzzy: {fuzzy_artist} - {fuzzy_song}") async def redis_store(self, sqlite_id: int, lyr_result: LyricsResult) -> None: """