Use rate limit retry-after response header to set sleep duration
When being rate limited, we get a retry-after header which tells us how long to wait before retrying, let's use it.
Thanks for the PR.
When did you encounter being rate limited?
@Neurrone I'm running beets with timid: yes and was iterating on a number of files that were being a bit stubborn and it was erroring out when trying to rename certain files (via use-as-is). This resulted in it re-querying a large number of books every time I restarted beets, because I believe beets still runs queries for books not yet processed. So it was kind of like:
- beets import ...
- try to fix the error on renaming
- error + exit
- beets import ...
- try to fix the error on renaming
When doing this in a large directory of unimported books (about 100), it didn't take long to get rate limited before I ran into the rate limit.