Skip to content

lyrics: give Genius its own, slower rate limit - #7232

Open
Sabrina04072003 wants to merge 1 commit into
beetbox:masterfrom
Sabrina04072003:lyrics-genius-rate-limit
Open

Sabrina04072003 wants to merge 1 commit into
beetbox:masterfrom
Sabrina04072003:lyrics-genius-rate-limit

Conversation

@Sabrina04072003

Copy link
Copy Markdown
Contributor

Related to #7226.

When many albums are imported, Genius can answer "too many 429 error responses".

All sites share one rate limit (0.25 s between requests). I think this is too fast for Genius.

This PR gives api.genius.com its own, slower limit (1 request per second). Other sites and the Tidal plugin are not changed.

The 1 second value is my estimate, and I could not test it against the real Genius API. I only checked by hand that api.genius.com gets a 1.0 s limit and other sites keep 0.25 s.

AI use: I used Claude to help me read the code and prepare this change.

@Sabrina04072003
Sabrina04072003 requested review from a team and snejus as code owners November 30, 2026 11:42
@github-actions github-actions Bot added the lyrics lyrics plugin label Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.95%. Comparing base (61ae14e) to head (9e34032).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7232      +/-   ##
==========================================
+ Coverage   80.93%   80.95%   +0.01%     
==========================================
  Files         150      150              
  Lines       21257    21258       +1     
  Branches     3246     3246              
==========================================
+ Hits        17205    17209       +4     
+ Misses       3244     3242       -2     
+ Partials      808      807       -1     
Files with missing lines Coverage Δ
beetsplug/_utils/requests.py 96.77% <100.00%> (+0.03%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Sabrina04072003

Copy link
Copy Markdown
Contributor Author

Hi! I opened a PR with the first option (a separate, slower rate limit for Genius only): #7232

The value (1 request per second) is my estimate. If you prefer another change, please let me know and I will update it. Thank you!

self.mount("https://", adapter)
self.mount("http://", adapter)

# Genius answers "429 Too Many Requests" when queried too fast, so it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong file for that logic. Genius rate limit should be defined the plugins code if possible. A bit of a strange coupling here.


Do we have any documentation for the rate limit? Is it really static? If it is not I would prefer an immediate retry and than an exponential backoff. We should have utils for this already too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lyrics lyrics plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants