Skip to content

feat: Add retry failed downloads feature with RETRY_FAILED_DOWNLOADS config (default: false), MAX_RETRY_ATTEMPTS config (default: 3) - #767#867

Open
shiva-sai-824 wants to merge 8 commits intoalexta69:masterfrom
shiva-sai-824:retry-failed-download
Open

feat: Add retry failed downloads feature with RETRY_FAILED_DOWNLOADS config (default: false), MAX_RETRY_ATTEMPTS config (default: 3) - #767#867
shiva-sai-824 wants to merge 8 commits intoalexta69:masterfrom
shiva-sai-824:retry-failed-download

Conversation

@shiva-sai-824
Copy link

@shiva-sai-824 shiva-sai-824 commented Jan 3, 2026

Summary

Implements automatic retry functionality for failed downloads with configurable maximum attempts, as requested in issue #767.

Backend Changes

Files: app/main.py, app/ytdl.py

  • Added RETRY_FAILED_DOWNLOADS configuration option (default: 'false')
  • Added MAX_RETRY_ATTEMPTS configuration option (default: '3')
  • Added retry_failed, max_retry_attempts, and retry_count fields to DownloadInfo class
  • Updated /add endpoint to accept retry_failed and max_retry_attempts parameters
  • Implemented automatic retry logic in _post_download_cleanup() method:
    • Checks if download failed and retry is enabled for that specific download
    • Compares current retry count against configured max attempts
    • Automatically re-queues failed downloads with incremented retry count
    • Status messages display "Retrying (attempt X/Y)" during retry attempts
    • Only marks download as permanently failed when max retries exhausted

Frontend Changes

Files: ui/src/app/app.ts, ui/src/app/app.html, ui/src/app/interfaces/download.ts, ui/src/app/services/downloads.service.ts

  • Added "Retry Failed Downloads" checkbox toggle in Advanced Options panel
  • Added "Max Retry Attempts" number input field (range: 1-10, default: 3)
  • Max attempts input automatically disabled when retry toggle is off
  • Settings persist in browser cookies (metube_retry_failed, metube_max_retry_attempts)
  • Updated DownloadsService.add() method to pass retry parameters to backend
  • Updated batch import functionality to include retry settings
  • Updated Download interface to include retry_failed, max_retry_attempts, and retry_count properties

Key Features

  • Per-download configuration: Each download can have its own retry settings
  • Opt-in feature: Disabled by default, must be explicitly enabled
  • Dual configuration: Can be set via environment variables (global default) or UI (per-download)
  • Retry limit enforcement: Prevents infinite retry loops with configurable max attempts
  • Clear status feedback: Shows retry progress in UI (e.g., "Retrying (attempt 2/3)")
  • Persistent settings: UI preferences saved in browser cookies

How It Works

  1. User enables "Retry Failed Downloads" toggle in Advanced Options
  2. Sets desired max retry attempts (1-10, default: 3)
  3. When a download is added, retry settings are included in the request
  4. If download fails:
    • Backend checks if retry_failed is enabled for that download
    • If retry count < max attempts: increment counter and re-queue automatically
    • If max attempts reached: mark as permanently failed
  5. UI displays retry status and current attempt number

Testing

  • UI controls tested and working correctly
  • Settings persistence verified
  • Download functionality confirmed
Screenshot 2026-01-02 at 8 58 40 PM

Resolves #767

…config (default: false), MAX_RETRY_ATTEMPTS config (default: 3) - alexta69#767
@shiva-sai-824
Copy link
Author

@alexta69 I raised new pr with updated master

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements automatic retry functionality for failed downloads with configurable maximum attempts. The feature is opt-in (disabled by default) and can be configured both globally via environment variables and per-download through the UI.

Key Changes

  • Added two new configuration options: RETRY_FAILED_DOWNLOADS (default: false) and MAX_RETRY_ATTEMPTS (default: 3)
  • Implemented automatic retry logic in the backend that re-queues failed downloads until max attempts are reached
  • Added UI controls (checkbox toggle and number input) in the Advanced Options panel for per-download retry configuration
  • Retry settings persist in browser cookies and are included in both individual and batch download requests

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
app/main.py Added retry configuration defaults and parameters to the /add endpoint
app/ytdl.py Extended DownloadInfo class with retry fields and implemented retry logic in _post_download_cleanup()
ui/src/app/app.ts Added retry settings properties, cookie persistence, and validation logic
ui/src/app/app.html Added UI controls for retry toggle and max attempts input field
ui/src/app/services/downloads.service.ts Updated add() method signature to include retry parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

app/main.py Outdated
Comment on lines +266 to +275
playlist_item_limit = int(playlist_item_limit)
max_retry_attempts = int(max_retry_attempts)
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

Missing error handling for type conversion. If max_retry_attempts or playlist_item_limit contain values that cannot be converted to integers (e.g., non-numeric strings), the int() conversion will raise a ValueError, causing a 500 error instead of a proper 400 Bad Request response. Consider wrapping these conversions in a try-except block and returning an appropriate error message.

Suggested change
playlist_item_limit = int(playlist_item_limit)
max_retry_attempts = int(max_retry_attempts)
try:
playlist_item_limit = int(playlist_item_limit)
max_retry_attempts = int(max_retry_attempts)
except (TypeError, ValueError):
log.error("Bad request: 'playlist_item_limit' and 'max_retry_attempts' must be integers")
raise web.HTTPBadRequest(text="'playlist_item_limit' and 'max_retry_attempts' must be integers")

Copilot uses AI. Check for mistakes.
shiva-sai-824 and others added 6 commits January 4, 2026 19:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refactor download creation and retry logic for better clarity and maintainability.
@shiva-sai-824
Copy link
Author

now u can review @alexta69

@alexta69
Copy link
Owner

alexta69 commented Jan 4, 2026

Thanks @shiva-sai-824 . I just noticed now that the README isn't updated with the new configuration variables, can you add them under the Download Behavior section? And then we can merge the PR.

@shiva-sai-824
Copy link
Author

I updated it can u check it and approve @alexta69 ?

@shiva-sai-824
Copy link
Author

@alexta69 still any changes needed??

@alexta69
Copy link
Owner

alexta69 commented Jan 8, 2026

@shiva-sai-824 Yes, sorry for the delays, but there are so many demands on our time these days. One final thing, I hope. The "max retry attempts" field appears even when the toggle is off, and it appears on the next line after the toggle. Another option we have there is "split by chapters", and it behaves differently -- the input box only appears when the toggle is on, and on the same line. Let's align the behavior. I suggest copying the behavior from the "split by chapters" feature.

@shiva-sai-824
Copy link
Author

Okay, I will try to implement it

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.

Feature request: Retry failed downloads

3 participants