Skip to content

Rate limit#8

Open
gabconcepcionph wants to merge 10 commits into
baairon:mainfrom
gabconcepcionph:rate-limit
Open

Rate limit#8
gabconcepcionph wants to merge 10 commits into
baairon:mainfrom
gabconcepcionph:rate-limit

Conversation

@gabconcepcionph

Copy link
Copy Markdown
Contributor

feat: streamline rate limiting with fixed batch limits and auto-resume

Consolidate batch progress display into Download section
Add animated MM:SS countdown for cooldown periods
Implement periodic auto-retry check for expired schedules (no manual intervention needed)
Display server error messages in rate limit banner (e.g., HTTP 429 details)
Persist batch counts across app restarts
Update README with rate limiting and batch download overview
Batch limits are: YouTube/Spotify (80 tracks, 30min cooldown), SoundCloud (160 tracks, 15min cooldown). Downloads auto-resume after cooldown with visible countdowns.

Replace global queue pause with per-source throttling. When a source hits rate limits or batch cap (20 downloads), pause only that source and schedule auto-resume while other sources continue. Track per-source download counts for pagination. Add Progress section to show scheduled resumes. Auto-resume sources on app startup when their scheduled time arrives.

- queue: pause only rate-limited source, not entire queue; schedule resume with timestamp
- queue: track per-source download counts;
Poll every second instead of every 5s to update the countdown timers and check for expired schedules. Track current time in state and refresh it every second so the Progress view shows live countdowns until each paused source auto-resumes.
Add batchLimits config for per-source rate limiting (youtube/soundcloud/spotify/link/local). Enforce 80% safety margin against platform limits (YouTube: 80, SoundCloud: 160, Spotify: 4800). Reset batch count after each pause so next resume starts fresh. Show batch progress in Progress view with warning icon at 80% threshold. Add Settings submenu for rate limit info and per-source batch config with validation.
… platform caps

Remove separate Spotify batch config since Spotify downloads via YouTube matching. Set source-specific defaults at 80% of platform limits (YouTube: 80, SoundCloud: 160) instead of flat 20. Map Spotify to YouTube's limit internally. Update UI to show "YouTube/Spotify batch" and display actual limits in progress counters. Add loadAllSchedules() to check expired schedules on startup. Use queue count for remaining items in Progress instead of stale
Save and restore perSourceCounts in queue snapshots so rate-limit tracking survives app restarts. Add perSourceCounts field to QueueSnapshot, pass the map to saveQueue/saveQueueSync, and restore it in queue.restore(). loadQueue() now returns both items and perSourceCounts. Prevents batch counters from resetting to zero on restart, which would allow exceeding platform limits after a quick restart.
Remove standalone Progress section and inline batch progress display into Download's QueueView. Show per-source batch counters (remaining/limit) below the queue header with warning icon at 80% threshold. Drop Progress from sidebar nav, keymap digit shortcuts (1-5 instead of 1-6), and footer hints. Batch progress now lives where downloads happen instead of a separate section.
Move batch counter reset from pause time (when hitting limit) to resume time (when schedule expires). Prevents counter from resetting immediately after pause, which would let it persist at the limit value across restarts. Counter now resets only when downloads actually resume, ensuring accurate rate-limit tracking through app restarts.
Track rateLimitResumeAt timestamp in queue stats and display live minute countdown in Download banner. Pass platform error message through DownloadResult so UI shows actual rate-limit reason instead of generic text. Count skipped items toward batch limit since they hit the API. Dedupe batch progress display by source ID instead of label to prevent double-counting. Emit update after batch count changes so UI reflects progress immediately.
Start interval timer on queue init to check scheduled resumes every 5s during runtime, not just on startup. Clear rateLimited flags when resuming a source so queue processing continues. Show live MM:SS countdown in both rate-limit banner and batch progress instead of rounded minutes. Display "batch complete" with next-batch countdown when limit hit instead of "0/limit left".
Add README section explaining per-source batch limits (YouTube/Spotify: 80, SoundCloud: 160), automatic cooldowns (30min/15min), and batch progress display format. Remove batch limit config options from Settings menu since limits are now hardcoded at 80% platform caps for safety.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant