Skip to content

Commit

Permalink
[Musixmatch] Handle non-200 status code
Browse files Browse the repository at this point in the history
Musixmatch returns
```
{'message': {'header': {'status_code': 401, 'execute_time': 0.0026848316192627, 'hint': 'captcha'}, 'body': []}}
```
after some requests, currently we return None to pass to the next provider, until we find a solution.
Fixes #35
  • Loading branch information
moehmeni committed May 18, 2024
1 parent 2e833ed commit 26022f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions syncedlyrics/providers/musixmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def get_lrc(self, search_term: str) -> Optional[str]:
("quorum_factor", "1.0"),
],
)
status_code = r.json()["message"]["header"]["status_code"]
if status_code != 200:
self.logger.warning(f"Got status code {status_code} for {search_term}")
return None
body = r.json()["message"]["body"]
tracks = body["track_list"]
cmp_key = lambda t: f"{t['track']['track_name']} {t['track']['artist_name']}"
Expand Down

0 comments on commit 26022f4

Please sign in to comment.