sptnr
sptnr copied to clipboard
Add per-song update lock, retry with rate limit handling, token refreshing, and fix bug with logged index
This PR introduces several improvements and fixes.
Features
Per-song Update Lock
- Added a locking mechanism per song to prevent redundant updates & request to spotify API.
- Lock duration has a 24hr jitter to prevent a stampede.
- Lock duration is configurable via argument
-d. - Specifying a lock duration of 0 will force an update.
Token Refreshing
- Spotify tokens expire after 60 minutes.
- Implemented automatic token refreshing 1minute before the token expires
- This ensures the Spotify token is always valid, and doesn't crash due to invalid token.
Retry with Rate Limit Handling
- Added retry logic for Rate Limited requests, Spotify Errors, and Timeouts.
- This includes exponential backoff, and respecting the Retry-After header returned by Spotify
Bug Fixes
Output Index Fix
- Corrects the output index with using the
--startargument. - Ensures that the displayed index reflects the correct global position.
Notes
- The locking allows the script to be re-run multiple times, only updating what is required, which is useful for libraries that are regularly updated.
- Retry and token refresh logic improves resilience against Spotify's API
Related Issues
resolves #9 resolves #8 partially #3
the lock file needs logs/ prepended to land in a docker volume, lock feature fails silently when run in a container as is.
other features working great, thank you.
the lock file needs logs/ prepended to land in a docker volume, lock feature fails silently when run in a container as is.
other features working great, thank you.
Thanks for letting me know, I don't really use docker much so didn't realize the lock couldn't be in the root. I've moved the lock file to the logs dir.