Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 27, 2025

BiliBili API returns HTTP 412 (Precondition Failed) as a non-standard rate limit response. The application would retry indefinitely on this error instead of stopping with a clear message.

Changes

  • Added RateLimitError exception (commons/utils.py)

    • Signals rate limit exceeded to stop retry loop
  • Enhanced exception handling (downmux/orchestrator.py)

    • Detects HTTP 412 + "Precondition Failed" in error messages/tracebacks
    • Pattern matches "HTTP Error 412:" or "HTTPError 412:" (with colon/space) to avoid false positives
    • Displays user message and raises RateLimitError to exit cleanly

Behavior

When rate limited, users see:

ERROR  Rate limit detected (HTTP 412: Precondition Failed)
ERROR  It appears you've made too many requests in a short period. Please take a break and try again after at least an hour.

Application exits instead of retrying.

Original prompt

On https://github.com/nattadasu/bilidownloader, can you add patch to automatically stop the app if yt-dlp throws ERROR: [BiliIntl] Unable to download video formats: HTTP Error 412: Precondition Failed (caused by <HTTPError 412: Precondition Failed>)?

Tell user if they need to chill out and wait for at least an hour. It's like a non-standard rate limiting btw. Rephrase my word so it's less direct


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add automatic app stop on yt-dlp HTTP error 412 Handle HTTP 412 rate limit errors from BiliBili API Dec 27, 2025
Copilot AI requested a review from nattadasu December 27, 2025 04:26
@nattadasu nattadasu closed this Dec 27, 2025
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.

2 participants