Skip to content

Commit

Permalink
Handle exception while searching for LRC
Browse files Browse the repository at this point in the history
Since we depend on providers and HTTP requests, there might be an API change or limit error at any time, thus I used exception handling to not abort the porgram. Resolves #37
  • Loading branch information
moehmeni committed May 23, 2024
1 parent 97dd3b3 commit af07c12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion syncedlyrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ def search(
lrc = None
for provider in _providers:
logger.debug(f"Looking for an LRC on {provider.__class__.__name__}")
_l = provider.get_lrc(search_term)
try:
_l = provider.get_lrc(search_term)
except Exception as e:
logger.error(
f"An error occurred while searching for an LRC on {provider.__class__.__name__}"
)
logger.error(e)
continue
if enhanced and not _l:
# Since enhanced is only supported by Musixmatch, break if no LRC is found
break
Expand Down

0 comments on commit af07c12

Please sign in to comment.