formatting / minor

This commit is contained in:
2025-11-22 21:43:48 -05:00
parent 3d0b867427
commit 353f14c899
7 changed files with 178 additions and 108 deletions

View File

@@ -46,7 +46,7 @@ class LRCLib:
async with AsyncSessionLocal() as db:
best_match = None
# Try exact match first (fastest)
result = await db.execute(
select(
@@ -63,7 +63,7 @@ class LRCLib:
.limit(1)
)
best_match = result.first()
# If no exact match, try prefix match (faster than full ILIKE)
if not best_match:
result = await db.execute(
@@ -81,7 +81,7 @@ class LRCLib:
.limit(1)
)
best_match = result.first()
# If still no match, try full ILIKE (slowest)
if not best_match:
result = await db.execute(
@@ -106,7 +106,7 @@ class LRCLib:
returned_artist = best_match.artist_name
returned_song = best_match.name
if plain:
if not best_match.plain_lyrics:
logging.info("No plain lyrics available on %s", self.label)
@@ -125,19 +125,18 @@ class LRCLib:
input_track = f"{artist} - {song}"
returned_track = f"{returned_artist} - {returned_song}"
match_result = self.matcher.find_best_match(
input_track=input_track,
candidate_tracks=[(0, returned_track)]
input_track=input_track, candidate_tracks=[(0, returned_track)]
)
if not match_result:
return None
_matched, confidence = match_result
logging.info("Result found on %s", self.label)
time_end = time.time()
time_diff = time_end - time_start
matched = LyricsResult(
artist=returned_artist,
song=returned_song,
@@ -146,10 +145,10 @@ class LRCLib:
confidence=confidence,
time=time_diff,
)
await self.redis_cache.increment_found_count(self.label)
return matched
except Exception as e:
logging.error("Exception in %s: %s", self.label, str(e))
return None